diff options
author | Wolfgang Müller <wolf@oriole.systems> | 2021-05-17 11:02:42 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-17 12:39:29 +0300 |
commit | 99fc555188681caeedc983b9fc982d6dc8ee2a8c (patch) | |
tree | c572e55b79db540fe660e753a8c9d9a606b28203 /t/t1500-rev-parse.sh | |
parent | 48bf2fa8bad054d66bd79c6ba903c89c704201f7 (diff) |
rev-parse: fix segfault with missing --path-format argument
Calling "git rev-parse --path-format" without an argument segfaults
instead of giving an error message. Commit fac60b8925 (rev-parse: add
option for absolute or relative path formatting, 2020-12-13) added the
argument parsing code but forgot to handle NULL.
Returning an error makes sense here because there is no default value we
could use. Add a test case to verify.
Signed-off-by: Wolfgang Müller <wolf@oriole.systems>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1500-rev-parse.sh')
-rwxr-xr-x | t/t1500-rev-parse.sh | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index deae916707..1c2df08333 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -146,6 +146,10 @@ test_expect_success '--path-format can change in the middle of the command line' test_cmp expect actual ' +test_expect_success '--path-format does not segfault without an argument' ' + test_must_fail git rev-parse --path-format +' + test_expect_success 'git-common-dir from worktree root' ' echo .git >expect && git rev-parse --git-common-dir >actual && |