Skip to content

Commit 0159ba3

Browse files
peffgitster
authored andcommitted
rev-list: don't show usage when we see empty ref patterns
If the user gives us no starting point for a traversal, we want to complain with our normal usage message. But if they tried to do so with "--all" or "--glob", but that happened not to match any refs, the usage message isn't helpful. We should just give them the empty output they asked for instead. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ba8262 commit 0159ba3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin/rev-list.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
350350

351351
if ((!revs.commits &&
352352
(!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
353-
!revs.pending.nr)) ||
353+
!revs.pending.nr) &&
354+
!revs.rev_input_given) ||
354355
revs.diff)
355356
usage(rev_list_usage);
356357

t/t6018-rev-list-glob.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ test_expect_failure 'rev-list should succeed with empty output on empty stdin' '
261261
test_cmp expect actual
262262
'
263263

264-
test_expect_failure 'rev-list should succeed with empty output with all refs excluded' '
264+
test_expect_success 'rev-list should succeed with empty output with all refs excluded' '
265265
>expect &&
266266
git rev-list --exclude=* --all >actual &&
267267
test_cmp expect actual
268268
'
269269

270-
test_expect_failure 'rev-list should succeed with empty output with empty --all' '
270+
test_expect_success 'rev-list should succeed with empty output with empty --all' '
271271
(
272272
test_create_repo empty &&
273273
cd empty &&
@@ -277,7 +277,7 @@ test_expect_failure 'rev-list should succeed with empty output with empty --all'
277277
)
278278
'
279279

280-
test_expect_failure 'rev-list should succeed with empty output with empty glob' '
280+
test_expect_success 'rev-list should succeed with empty output with empty glob' '
281281
>expect &&
282282
git rev-list --glob=does-not-match-anything >actual &&
283283
test_cmp expect actual

0 commit comments

Comments
 (0)