git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-bisect: do not get confused by packed-ref

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 27, 2007, 06:50 UTC
Message-ID
<7v1weu49y9.fsf@assigned-by-dhcp.cox.net>

If an unfortunate user runs a pack-ref while a git-bisect is active, refs/bisect/* references will stay behind even after the git-bisect finishes, because the clean-up code only paid attention to loose refs. This has a potential to confuse later bisect runs greatly.

Ideally we should further fix parts that manually creates the good references refs/bisect/good-*, and updates bad reference refs/bisect/bad, but that is a cleanliness not correctness issue. For 1.5.3, this minimum fix should do.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-bisect.sh |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index 388887a..77dad51 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -265,8 +265,16 @@ bisect_reset() {
 }
 
 bisect_clean_state() {
+	git for-each-ref --format='%(objectname) %(refname)' refs/bisect |
+	while read sha1 ref
+	do
+		git update-ref -d "$ref" "$sha1"
+	done
+	if current=$(git rev-parse --verify refs/heads/bisect 2>/dev/null)
+	then
+		git update-ref -d refs/heads/bisect "$current"
+	fi
 	rm -fr "$GIT_DIR/refs/bisect"
-	rm -f "$GIT_DIR/refs/heads/bisect"
 	rm -f "$GIT_DIR/BISECT_LOG"
 	rm -f "$GIT_DIR/BISECT_NAMES"
 	rm -f "$GIT_DIR/BISECT_RUN"
Message 1 of 1 in “git-bisect: do not get confused by packed-ref”
  1. git-bisect: do not get confused by packed-refJunio C Hamano, Jul 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.