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

Re: [PATCH 5/5] Enable ref log creation in git checkout -b.

From
Shawn Pearce <spearce@spearce.org>
Date
May 24, 2006, 23:36 UTC
Message-ID
<20060524233646.GC3554@spearce.org>
In-Reply-To
<7vy7wr3tc3.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 16 quoted lines
> Shawn Pearce <spearce@spearce.org> writes:
> 
> > Junio C Hamano <junkio@cox.net> wrote:
> >> I've swallowed all 10 and pushed them out in "pu", but could you
> >> add tests to check the Porcelainish commands you touched with
> >> this series to make sure they all log correctly?
> >
> > Sure.  I've been putting it off as I've been busy the past few days
> > and have also been thinking about trying to rebuild reflog using a
> > tag/annotation branch style, which might be more generally useful
> > to others.
> 
> It appears that there is more serious breakage caused by the
> lock_ref change.  http-fetch in "next" fails to clone, because
> the call to lock-ref-sha1 in fetch.c::pull() forgets that the
> program might be creating a new ref.

The breakage is because of current_ref always being null. The old code would allow locking a non-existant ref in this case while the new code was failing. A simple change such as the following should fix it:

-->8-- Fix fetch when using reflog.

Previously fetch was permitted to create refs if they did not exist; this only worked as current_ref was always NULL and thus never would get compared against the existing ref.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
2dad4178db978c01257fde949d808361589ee003
 fetch.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
2dad4178db978c01257fde949d808361589ee003
diff --git a/fetch.c b/fetch.c
index fd57684..15110b8 100644
--- a/fetch.c
+++ b/fetch.c
@@ -213,7 +213,7 @@ int pull(char *target)
 	save_commit_buffer = 0;
 	track_object_refs = 0;
 	if (write_ref) {
-		lock = lock_ref_sha1(write_ref, current_ref, 1);
+		lock = lock_ref_sha1(write_ref, current_ref, 0);
 		if (!lock) {
 			error("Can't lock ref %s", write_ref);
 			return -1;
-- 
1.3.3.gfad60
Previous: Shawn Pearce
Message 7 of 7 in “Enable ref log creation in git checkout -b.”
  1. 5/5 Enable ref log creation in git checkout -b.Shawn Pearce, May 19, 2006
  2. Junio C HamanoMay 21, 2006
  3. Shawn PearceMay 24, 2006
  4. Junio C HamanoMay 24, 2006
  5. Junio C HamanoMay 24, 2006
  6. Shawn PearceMay 24, 2006
  7. Shawn PearceMay 24, 2006

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.