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
This commit is contained in:
@ -759,6 +759,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (opt_with_value(arg, "--path-format", &arg)) {
|
if (opt_with_value(arg, "--path-format", &arg)) {
|
||||||
|
if (!arg)
|
||||||
|
die("--path-format requires an argument");
|
||||||
if (!strcmp(arg, "absolute")) {
|
if (!strcmp(arg, "absolute")) {
|
||||||
format = FORMAT_CANONICAL;
|
format = FORMAT_CANONICAL;
|
||||||
} else if (!strcmp(arg, "relative")) {
|
} else if (!strcmp(arg, "relative")) {
|
||||||
|
@ -146,6 +146,10 @@ test_expect_success '--path-format can change in the middle of the command line'
|
|||||||
test_cmp expect actual
|
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' '
|
test_expect_success 'git-common-dir from worktree root' '
|
||||||
echo .git >expect &&
|
echo .git >expect &&
|
||||||
git rev-parse --git-common-dir >actual &&
|
git rev-parse --git-common-dir >actual &&
|
||||||
|
Reference in New Issue
Block a user