From: David Turner Date: Wed, 26 Aug 2015 19:46:05 GMT Subject: [PATCH v4 4/4] bisect: make bisection refs per-worktree Message-ID: <1440618365-20628-5-git-send-email-dturner@twopensource.com> In-Reply-To: <1440618365-20628-1-git-send-email-dturner@twopensource.com> Using the new refs/worktree/ refs, make bisection per-worktree. Signed-off-by: David Turner --- Documentation/git-bisect.txt | 4 ++-- Documentation/rev-list-options.txt | 14 +++++++------- bisect.c | 2 +- builtin/rev-parse.c | 6 ++++-- git-bisect.sh | 14 +++++++------- revision.c | 2 +- t/t6030-bisect-porcelain.sh | 20 ++++++++++---------- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index e97f2de..f0c52d1 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -82,7 +82,7 @@ to ask for the next commit that needs testing. Eventually there will be no more revisions left to inspect, and the command will print out a description of the first bad commit. The -reference `refs/bisect/bad` will be left pointing at that commit. +reference `refs/worktree/bisect/bad` will be left pointing at that commit. Bisect reset @@ -373,7 +373,7 @@ on a single line. ------------ $ git bisect start HEAD [ ... ] --no-checkout $ git bisect run sh -c ' - GOOD=$(git for-each-ref "--format=%(objectname)" refs/bisect/good-*) && + GOOD=$(git for-each-ref "--format=%(objectname)" refs/worktree/bisect/good-*) && git rev-list --objects BISECT_HEAD --not $GOOD >tmp.$$ && git pack-objects --stdout >/dev/null >"$GIT_DIR/BISECT_LOG" test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } @@ -282,8 +282,8 @@ bisect_state() { bisect_next_check() { missing_good= missing_bad= - git show-ref -q --verify refs/bisect/$TERM_BAD || missing_bad=t - test -n "$(git for-each-ref "refs/bisect/$TERM_GOOD-*")" || missing_good=t + git show-ref -q --verify refs/worktree/bisect/$TERM_BAD || missing_bad=t + test -n "$(git for-each-ref "refs/worktree/bisect/$TERM_GOOD-*")" || missing_good=t case "$missing_good,$missing_bad,$1" in ,,*) @@ -341,15 +341,15 @@ bisect_next() { # Check if we should exit because bisection is finished if test $res -eq 10 then - bad_rev=$(git show-ref --hash --verify refs/bisect/$TERM_BAD) + bad_rev=$(git show-ref --hash --verify refs/worktree/bisect/$TERM_BAD) bad_commit=$(git show-branch $bad_rev) echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG" exit 0 elif test $res -eq 2 then echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG" - good_revs=$(git for-each-ref --format="%(objectname)" "refs/bisect/$TERM_GOOD-*") - for skipped in $(git rev-list refs/bisect/$TERM_BAD --not $good_revs) + good_revs=$(git for-each-ref --format="%(objectname)" "refs/worktree/bisect/$TERM_GOOD-*") + for skipped in $(git rev-list refs/worktree/bisect/$TERM_BAD --not $good_revs) do skipped_commit=$(git show-branch $skipped) echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG" @@ -412,7 +412,7 @@ Try 'git bisect reset '.")" bisect_clean_state() { # There may be some refs packed during bisection. - git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* | + git for-each-ref --format='%(refname) %(objectname)' refs/worktree/bisect/\* | while read ref hash do git update-ref -d $ref $hash || exit diff --git a/revision.c b/revision.c index b6b2cf7..974a11f 100644 --- a/revision.c +++ b/revision.c @@ -2084,7 +2084,7 @@ extern void read_bisect_terms(const char **bad, const char **good); static int for_each_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data, const char *term) { struct strbuf bisect_refs = STRBUF_INIT; int status; - strbuf_addf(&bisect_refs, "refs/bisect/%s", term); + strbuf_addf(&bisect_refs, "refs/worktree/bisect/%s", term); status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data); strbuf_release(&bisect_refs); return status; diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 9e2c203..bfd5463 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -68,7 +68,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' ' git bisect reset && test_must_fail git bisect start foo $HASH1 -- && test_must_fail git bisect start $HASH4 $HASH1 bar -- && - test -z "$(git for-each-ref "refs/bisect/*")" && + test -z "$(git for-each-ref "refs/worktree/bisect/*")" && test -z "$(ls .git/BISECT_* 2>/dev/null)" && git bisect start && test_must_fail git bisect good foo $HASH1 && @@ -77,7 +77,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' ' test_must_fail git bisect bad $HASH3 $HASH4 && test_must_fail git bisect skip bar $HASH3 && test_must_fail git bisect skip $HASH1 foo && - test -z "$(git for-each-ref "refs/bisect/*")" && + test -z "$(git for-each-ref "refs/worktree/bisect/*")" && git bisect good $HASH1 && git bisect bad $HASH4 ' @@ -115,7 +115,7 @@ test_expect_success 'bisect reset removes packed refs' ' git pack-refs --all --prune && git bisect next && git bisect reset && - test -z "$(git for-each-ref "refs/bisect/*")" && + test -z "$(git for-each-ref "refs/worktree/bisect/*")" && test -z "$(git for-each-ref "refs/heads/bisect")" ' @@ -126,7 +126,7 @@ test_expect_success 'bisect reset removes bisect state after --no-checkout' ' git bisect bad $HASH3 && git bisect next && git bisect reset && - test -z "$(git for-each-ref "refs/bisect/*")" && + test -z "$(git for-each-ref "refs/worktree/bisect/*")" && test -z "$(git for-each-ref "refs/heads/bisect")" && test -z "$(git for-each-ref "BISECT_HEAD")" ' @@ -176,7 +176,7 @@ test_expect_success 'bisect start: no ".git/BISECT_START" if checkout error' ' git branch > branch.output && grep "* other" branch.output > /dev/null && test_must_fail test -e .git/BISECT_START && - test -z "$(git for-each-ref "refs/bisect/*")" && + test -z "$(git for-each-ref "refs/worktree/bisect/*")" && git checkout HEAD hello ' @@ -671,7 +671,7 @@ test_expect_success 'bisect: --no-checkout - target before breakage' ' git bisect bad BISECT_HEAD && check_same BROKEN_HASH5 BISECT_HEAD && git bisect bad BISECT_HEAD && - check_same BROKEN_HASH5 bisect/bad && + check_same BROKEN_HASH5 refs/worktree/bisect/bad && git bisect reset ' @@ -682,7 +682,7 @@ test_expect_success 'bisect: --no-checkout - target in breakage' ' git bisect bad BISECT_HEAD && check_same BROKEN_HASH5 BISECT_HEAD && git bisect good BISECT_HEAD && - check_same BROKEN_HASH6 bisect/bad && + check_same BROKEN_HASH6 refs/worktree/bisect/bad && git bisect reset ' @@ -693,7 +693,7 @@ test_expect_success 'bisect: --no-checkout - target after breakage' ' git bisect good BISECT_HEAD && check_same BROKEN_HASH8 BISECT_HEAD && git bisect good BISECT_HEAD && - check_same BROKEN_HASH9 bisect/bad && + check_same BROKEN_HASH9 refs/worktree/bisect/bad && git bisect reset ' @@ -702,13 +702,13 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' " git checkout broken && git bisect start broken master --no-checkout && git bisect run \"\$SHELL_PATH\" -c ' - GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) && + GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/worktree/bisect/good-*) && git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ && git pack-objects --stdout >/dev/null < tmp.\$\$ rc=\$? rm -f tmp.\$\$ test \$rc = 0' && - check_same BROKEN_HASH6 bisect/bad && + check_same BROKEN_HASH6 refs/worktree/bisect/bad && git bisect reset " -- 2.4.2.622.gac67c30-twtrsrc