Skip to contentSkip to conversation

bisect reset: Leave the tree in usable state if git-checkout failed

PATCH In review Petr Baudis 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bisect reset: Leave the tree in usable state if git-checkout failed

I had local modifications in the tree and doing bisect reset required me to manually edit .git/HEAD.

---

 git-bisect.sh |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
git-bisect.sh +6 -5
index 06a8d26..09cd179 100755
@@ -179,11 +179,12 @@ bisect_reset() {
         *)
 	    usage ;;
 	esac
-	git checkout "$branch" &&
-	rm -fr "$GIT_DIR/refs/bisect"
-	rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
-	rm -f "$GIT_DIR/BISECT_LOG"
-	rm -f "$GIT_DIR/BISECT_NAMES"
+	if ! git checkout "$branch"; then
+		rm -fr "$GIT_DIR/refs/bisect"
+		rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
+		rm -f "$GIT_DIR/BISECT_LOG"
+		rm -f "$GIT_DIR/BISECT_NAMES"
+	fi
 }
 
 bisect_replay () {
#1 lore raw

Dear diary, on Mon, Oct 16, 2006 at 02:59:25AM CEST, I got a letter where Petr Baudis <[email protected]> said that...

Quoted 14 lines

I had local modifications in the tree and doing bisect reset required me to manually edit .git/HEAD.

---

 git-bisect.sh |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
git-bisect.sh +0 -0
index 06a8d26..09cd179 100755

git-bisect.sh bisect_reset() { · line 182

Quoted 9 lines
git-bisect.sh +1 -5
@@ -179,11 +179,12 @@ bisect_reset() {
         *)
 	    usage ;;
 	esac
-	git checkout "$branch" &&
-	rm -fr "$GIT_DIR/refs/bisect"
-	rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
-	rm -f "$GIT_DIR/BISECT_LOG"
-	rm -f "$GIT_DIR/BISECT_NAMES"
+	if ! git checkout "$branch"; then

Doh, please drop the !. I had it that way before and added the negation mark as a last-minute "fix". :/ Sorry. Not being too good at doing random shell fixes in the middle of C coding.

Quoted 8 lines
git-bisect.sh +5 -0
+		rm -fr "$GIT_DIR/refs/bisect"
+		rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
+		rm -f "$GIT_DIR/BISECT_LOG"
+		rm -f "$GIT_DIR/BISECT_NAMES"
+	fi
 }
 
 bisect_replay () {
Signature · 5 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)