git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bisect: use update-ref to update refs
@ 2007-03-28 12:35 Uwe Kleine-König
  2007-03-28 13:46 ` Johannes Sixt
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2007-03-28 12:35 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bisect: use update-ref to update refs
  2007-03-28 12:35 [PATCH] bisect: use update-ref to update refs Uwe Kleine-König
@ 2007-03-28 13:46 ` Johannes Sixt
  2007-03-28 14:10   ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Sixt @ 2007-03-28 13:46 UTC (permalink / raw)
  To: git

Uwe Kleine-König wrote:
>         GIT_DIR="$GIT_DIR" git-$command ...
> 
> where the assignment to GIT_DIR should be superfluous?

git-sh-setup sets GIT_DIR, but does not export it. Therefore, this
assignment is *not* superfluous (its effect is to export GIT_DIR for
this command only).

-- Hannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bisect: use update-ref to update refs
  2007-03-28 13:46 ` Johannes Sixt
@ 2007-03-28 14:10   ` Uwe Kleine-König
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2007-03-28 14:10 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Johannes Sixt wrote:
> Uwe Kleine-König wrote:
> >         GIT_DIR="$GIT_DIR" git-$command ...
> > 
> > where the assignment to GIT_DIR should be superfluous?
> 
> git-sh-setup sets GIT_DIR, but does not export it. Therefore, this
> assignment is *not* superfluous (its effect is to export GIT_DIR for
> this command only).
..., but why do only two invocations of git get GIT_DIR="$GIT_DIR" and
the other 20+ don't?

Best regards
Uwe

-- 
Uwe Kleine-König

http://www.google.com/search?q=sine+of+%2830+degree%29

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-28 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 12:35 [PATCH] bisect: use update-ref to update refs Uwe Kleine-König
2007-03-28 13:46 ` Johannes Sixt
2007-03-28 14:10   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).