Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Git Mailing List <git@vger.kernel.org>,
	Davide Libenzi <davidel@xmailserver.org>
Subject: Re: Add "git-update-ref" to update the HEAD (or other) ref
Date: Sun, 25 Sep 2005 16:27:44 -0700	[thread overview]
Message-ID: <7vhdc8n2xb.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0509251134480.3308@g5.osdl.org> (Linus Torvalds's message of "Sun, 25 Sep 2005 11:43:05 -0700 (PDT)")

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);

  parent reply	other threads:[~2005-09-25 23:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-25 18:43 Add "git-update-ref" to update the HEAD (or other) ref Linus Torvalds
2005-09-25 19:05 ` Linus Torvalds
2005-09-25 22:37   ` Junio C Hamano
2005-09-28  2:45   ` [PATCH] Use git-update-ref in scripts Junio C Hamano
2005-09-28 15:21     ` Linus Torvalds
2005-09-28 16:56       ` Junio C Hamano
2005-09-28 17:13         ` Linus Torvalds
2005-09-28 17:29           ` Junio C Hamano
2005-09-28 18:14             ` Linus Torvalds
2005-09-28 18:28               ` Junio C Hamano
2005-09-29 16:07                 ` Linus Torvalds
2005-09-28 18:17           ` Junio C Hamano
2005-09-28 19:47             ` Junio C Hamano
2005-09-28 21:19               ` Fredrik Kuivinen
2005-09-29 15:16             ` Linus Torvalds
2005-09-25 23:27 ` Junio C Hamano [this message]
2005-09-26  0:50   ` Add "git-update-ref" to update the HEAD (or other) ref Linus Torvalds
2005-09-26  4:25     ` Junio C Hamano
2005-09-26  1:07   ` Linus Torvalds

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=7vhdc8n2xb.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=davidel@xmailserver.org \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox