diff options
-rw-r--r-- | builtin/commit-graph.c | 1 | ||||
-rwxr-xr-x | t/t5318-commit-graph.sh | 16 |
2 files changed, 16 insertions, 1 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 0457903f18..21fc6e934b 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -345,6 +345,7 @@ int cmd_commit_graph(int argc, const char **argv, const char *prefix) else if (argc && !strcmp(argv[0], "write")) return graph_write(argc, argv); + error(_("unrecognized subcommand: %s"), argv[0]); usage: usage_with_options(builtin_commit_graph_usage, builtin_commit_graph_options); diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 09a2ccd292..295c5bd94d 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -6,10 +6,24 @@ test_description='commit graph' GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0 test_expect_success 'usage' ' - test_expect_code 129 git commit-graph write blah && + test_expect_code 129 git commit-graph write blah 2>err && test_expect_code 129 git commit-graph write verify ' +test_expect_success 'usage shown without sub-command' ' + test_expect_code 129 git commit-graph 2>err && + ! grep error: err +' + +test_expect_success 'usage shown with an error on unknown sub-command' ' + cat >expect <<-\EOF && + error: unrecognized subcommand: unknown + EOF + test_expect_code 129 git commit-graph unknown 2>stderr && + grep error stderr >actual && + test_cmp expect actual +' + test_expect_success 'setup full repo' ' mkdir full && cd "$TRASH_DIRECTORY/full" && |