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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Aug 2, 2017 at 18:26 UTC
0159ba3226f75fbd6d3dc0e92c325cb11f2f0699
2 files changed
+5
-4
builtin/rev-list.c
+2
-1
@@ -350,7 +350,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
350
351
if ((!revs.commits &&
352
(!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
353
- !revs.pending.nr)) ||
353
+ !revs.pending.nr) &&
354
+ !revs.rev_input_given) ||
355
revs.diff)
356
usage(rev_list_usage);
357
t/t6018-rev-list-glob.sh
+3
-3
@@ -261,13 +261,13 @@ test_expect_failure 'rev-list should succeed with empty output on empty stdin' '
261
test_cmp expect actual
262
'
263
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' '
265
>expect &&
266
git rev-list --exclude=* --all >actual &&
267
test_cmp expect actual
268
'
269
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' '
271
(
272
test_create_repo empty &&
273
cd empty &&
@@ -277,7 +277,7 @@ test_expect_failure 'rev-list should succeed with empty output with empty --all'
277
)
278
'
279
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' '
281
>expect &&
282
git rev-list --glob=does-not-match-anything >actual &&
283
test_cmp expect actual