Skip to content

Commit 03a0182

Browse files
committed
Merge branch 'cc/bisect-start-fix'
"git bisect start X Y", when X and Y are not valid committish object names, should take X and Y as pathspec, but didn't. * cc/bisect-start-fix: bisect: don't use invalid oid as rev when starting
2 parents 230ff3e + 73c6de0 commit 03a0182

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

builtin/bisect--helper.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,13 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc)
484484
terms->term_bad = xstrdup(arg);
485485
} else if (starts_with(arg, "--")) {
486486
return error(_("unrecognized option: '%s'"), arg);
487-
} else {
488-
char *commit_id = xstrfmt("%s^{commit}", arg);
489-
if (get_oid(commit_id, &oid) && has_double_dash)
490-
die(_("'%s' does not appear to be a valid "
491-
"revision"), arg);
492-
487+
} else if (!get_oidf(&oid, "%s^{commit}", arg)) {
493488
string_list_append(&revs, oid_to_hex(&oid));
494-
free(commit_id);
489+
} else if (has_double_dash) {
490+
die(_("'%s' does not appear to be a valid "
491+
"revision"), arg);
492+
} else {
493+
break;
495494
}
496495
}
497496
pathspec_pos = i;

t/t6030-bisect-porcelain.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
8282
git bisect bad $HASH4
8383
'
8484

85+
test_expect_success 'bisect start without -- takes unknown arg as pathspec' '
86+
git bisect reset &&
87+
git bisect start foo bar &&
88+
grep foo ".git/BISECT_NAMES" &&
89+
grep bar ".git/BISECT_NAMES"
90+
'
91+
8592
test_expect_success 'bisect reset: back in the master branch' '
8693
git bisect reset &&
8794
echo "* master" > branch.expect &&

0 commit comments

Comments
 (0)