Is reserving the branch name "bisect" a good thing?
From: <hidden>
Date: 2016-06-15 22:42:14
Subsystem:
the rest · Maintainer:
Linus Torvalds
Just wondering... most of the "magic" references are in $GIT_DIR directly, and ALL_CAPS. "git bisect start" begins with "rm -f $GIT_DIR/refs/heads/bisect", which could catch someone trying to implement a bisection algorithm in their own code. Would it be better if "git bisect" followed that rule as well? Otherwise, we really should document the reserved word. Either that, or use refs/bisect/current and avoid the issue entirely. Something like (untested):
diff --git a/git-bisect.sh b/git-bisect.sh
index 68838f3..19a8f36 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh@@ -50,7 +50,7 @@ bisect_start() { head=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) || die "Bad HEAD - I need a symbolic ref" case "$head" in - refs/heads/bisect*) + BISECT*) git checkout master || exit ;; refs/heads/*)
@@ -63,7 +63,7 @@ bisect_start() { # # Get rid of any old bisect state # - rm -f "$GIT_DIR/refs/heads/bisect" + rm -f "$GIT_DIR/BISECT" rm -rf "$GIT_DIR/refs/bisect/" mkdir "$GIT_DIR/refs/bisect" {
@@ -146,10 +146,10 @@ bisect_next() { fi nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit echo "Bisecting: $nr revisions left to test after this" - echo "$rev" > "$GIT_DIR/refs/heads/new-bisect" - git checkout new-bisect || exit - mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" && - GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect + echo "$rev" > "$GIT_DIR/NEW-BISECT" + git checkout NEW-BISECT || exit + mv "$GIT_DIR/NEW-BISECT" "$GIT_DIR/BISECT" && + GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD BISECT git-show-branch "$rev" }
@@ -172,7 +172,7 @@ bisect_reset() { esac git checkout "$branch" && rm -fr "$GIT_DIR/refs/bisect" - rm -f "$GIT_DIR/refs/heads/bisect" + rm -f "$GIT_DIR/BISECT" rm -f "$GIT_DIR/BISECT_LOG" }