All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <ukleinek@informatik.uni-freiburg.de>
To: git@vger.kernel.org
Subject: [PATCH] bisect: use update-ref to update refs
Date: Wed, 28 Mar 2007 14:35:20 +0200	[thread overview]
Message-ID: <20070328123519.GA4472@cepheus> (raw)

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@informatik.uni-freiburg.de>
---

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

             reply	other threads:[~2007-03-28 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-28 12:35 Uwe Kleine-König [this message]
2007-03-28 13:46 ` [PATCH] bisect: use update-ref to update refs Johannes Sixt
2007-03-28 14:10   ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070328123519.GA4472@cepheus \
    --to=ukleinek@informatik.uni-freiburg.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.