[PATCH] bisect: use update-ref to update refs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



update-ref is safer than manualy echoing values to various files in
$GIT_DIR/refs/heads/.

bisect predates update-ref and was never updated to use the latter.

Signed-off-by: Uwe Kleine-König <ukleinek@xxxxxxxxxxxxxxxxxxxxxxxxxx>
---

There are some style nits in git-bisect.sh that I found while producing that
patch.  E.g. the 3rd hunk shows 

	GIT_DIR="$GIT_DIR" git-$command ...

where the assignment to GIT_DIR should be superfluous?  In some places
git-command is used, and in other git command.

 git-bisect.sh |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/git-bisect.sh b/git-bisect.sh
index a12ea31..1589870 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -90,7 +90,7 @@ bisect_bad() {
 	*)
 		usage ;;
 	esac || exit
-	echo "$rev" >"$GIT_DIR/refs/bisect/bad"
+	git update-ref "refs/bisect/bad" "$rev"
 	echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
 	echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
 	bisect_auto_next
@@ -106,7 +106,7 @@ bisect_good() {
 	for rev in $revs
 	do
 		rev=$(git-rev-parse --verify "$rev^{commit}") || exit
-		echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
+		git update-ref "refs/bisect/good-$rev" "$rev"
 		echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
 		echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
 	done
@@ -159,9 +159,10 @@ bisect_next() {
 		nr="$nr_good";
 	fi;
 	echo "Bisecting: maximal $nr revisions left to test"
-	echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
+	git update-ref refs/heads/new-bisect "$rev"
 	git checkout -q new-bisect || exit
-	mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
+	git update-ref refs/heads/bisect "$rev" &&
+	git update-ref -d refs/heads/new-bisect "$rev" &&
 	GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect
 	git-show-branch "$rev"
 }
@@ -211,12 +212,12 @@ bisect_replay () {
 			eval "$cmd"
 			;;
 		good)
-			echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
+			git update-ref "refs/bisect/good-$rev" "$rev"
 			echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
 			echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
 			;;
 		bad)
-			echo "$rev" >"$GIT_DIR/refs/bisect/bad"
+			git update-ref "refs/bisect/bad" "$rev"
 			echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
 			echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
 			;;
-- 
1.5.0.2.260.g2eb065


-- 
Uwe Kleine-König

http://www.google.com/search?q=1+newton+in+kg*m+%2F+s%5E2
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]