Re: Add "git-update-ref" to update the HEAD (or other) ref

From: Junio C Hamano <junkio@cox.net>
Date: 2005-09-26 09:27:44
Linus Torvalds <torvalds@osdl.org> writes:

> +	 * FIXME!

Is something like the one at the end acceptable?

I'd like to take these patches in two stages (I am not asking
you for a resend):

 - Drop the emulated symlink part from the update-ref.c; have it
   graduate to "master" branch and use it in existing scripts.

 - Take the read_ref() change, along with a patch to re-add the
   emulated symlink part to update-ref.c (after making its
   interpretation to match that of read_ref() -- which requires
   the prefix to be exactly "ref: " five bytes); keep it in "pu"
   branch a bit longer.


---
diff --git a/update-ref.c b/update-ref.c
--- a/update-ref.c
+++ b/update-ref.c
@@ -97,11 +97,13 @@ int main(int argc, char **argv)
 	}
 
 	/*
-	 * FIXME!
-	 *
-	 * We should re-read the old ref here, and re-verify that it
+	 * We re-read the old ref here, and re-verify that it
 	 * matches "oldsha1". Otherwise there's a small race.
 	 */
+	if (!resolve_ref(git_path("%s", refname), oldsha1))
+		die("Cannot verify ref: %s", refname); 
+	if (memcmp(oldsha1, currsha1, 20))
+		die("Ref %s changed to %s", refname, sha1_to_hex(oldsha1));
 
 	if (rename(lockpath, path) < 0) {
 		unlink(lockpath);

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Mon Sep 26 09:30:13 2005

This archive was generated by hypermail 2.1.8 : 2005-09-26 09:30:16 EST