Skip to content

Commit 99fe1c6

Browse files
committed
Merge branch 'wm/rev-parse-path-format-wo-arg'
The "rev-parse" command did not diagnose the lack of argument to "--path-format" option, which was introduced in v2.31 era, which has been corrected. * wm/rev-parse-path-format-wo-arg: rev-parse: fix segfault with missing --path-format argument
2 parents 107691c + 99fc555 commit 99fe1c6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

builtin/rev-parse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
759759
continue;
760760
}
761761
if (opt_with_value(arg, "--path-format", &arg)) {
762+
if (!arg)
763+
die("--path-format requires an argument");
762764
if (!strcmp(arg, "absolute")) {
763765
format = FORMAT_CANONICAL;
764766
} else if (!strcmp(arg, "relative")) {

t/t1500-rev-parse.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ test_expect_success '--path-format can change in the middle of the command line'
146146
test_cmp expect actual
147147
'
148148

149+
test_expect_success '--path-format does not segfault without an argument' '
150+
test_must_fail git rev-parse --path-format
151+
'
152+
149153
test_expect_success 'git-common-dir from worktree root' '
150154
echo .git >expect &&
151155
git rev-parse --git-common-dir >actual &&

0 commit comments

Comments
 (0)