git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
Sep 25, 2005, 23:27 UTC
Message-ID
<7vhdc8n2xb.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0509251134480.3308@g5.osdl.org>
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);
Previous: Linus TorvaldsNext: Linus Torvalds
Message 16 of 19 in “Add "git-update-ref" to update the HEAD (or other) ref”
  1. Linus TorvaldsSep 25, 2005
  2. Linus TorvaldsSep 25, 2005
  3. Junio C HamanoSep 25, 2005
  4. Use git-update-ref in scripts.Junio C Hamano, Sep 28, 2005
  5. Linus TorvaldsSep 28, 2005
  6. Junio C HamanoSep 28, 2005
  7. Linus TorvaldsSep 28, 2005
  8. Junio C HamanoSep 28, 2005
  9. Linus TorvaldsSep 28, 2005
  10. Junio C HamanoSep 28, 2005
  11. Linus TorvaldsSep 29, 2005
  12. Junio C HamanoSep 28, 2005
  13. Junio C HamanoSep 28, 2005
  14. Fredrik KuivinenSep 28, 2005
  15. Linus TorvaldsSep 29, 2005
  16. Junio C HamanoSep 25, 2005
  17. Linus TorvaldsSep 26, 2005
  18. Junio C HamanoSep 26, 2005
  19. Linus TorvaldsSep 26, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.