Skip to content

Commit 35381b1

Browse files
committed
Merge branch 'jk/bisect-peel-tag-fix'
"git bisect" reimplemented more in C during 2.30 timeframe did not take an annotated tag as a good/bad endpoint well. This regression has been corrected. * jk/bisect-peel-tag-fix: bisect: peel annotated tags to commits
2 parents 8779c14 + 7730f85 commit 35381b1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

builtin/bisect--helper.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,19 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a
874874
*/
875875

876876
for (; argc; argc--, argv++) {
877+
struct commit *commit;
878+
877879
if (get_oid(*argv, &oid)){
878880
error(_("Bad rev input: %s"), *argv);
879881
oid_array_clear(&revs);
880882
return BISECT_FAILED;
881883
}
882-
oid_array_append(&revs, &oid);
884+
885+
commit = lookup_commit_reference(the_repository, &oid);
886+
if (!commit)
887+
die(_("Bad rev input (not a commit): %s"), *argv);
888+
889+
oid_array_append(&revs, &commit->object.oid);
883890
}
884891

885892
if (strbuf_read_file(&buf, git_path_bisect_expected_rev(), 0) < the_hash_algo->hexsz ||

t/t6030-bisect-porcelain.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,4 +939,16 @@ test_expect_success 'git bisect reset cleans bisection state properly' '
939939
test_path_is_missing ".git/BISECT_START"
940940
'
941941

942+
test_expect_success 'bisect handles annotated tags' '
943+
test_commit commit-one &&
944+
git tag -m foo tag-one &&
945+
test_commit commit-two &&
946+
git tag -m foo tag-two &&
947+
git bisect start &&
948+
git bisect good tag-one &&
949+
git bisect bad tag-two >output &&
950+
bad=$(git rev-parse --verify tag-two^{commit}) &&
951+
grep "$bad is the first bad commit" output
952+
'
953+
942954
test_done

0 commit comments

Comments
 (0)