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

Re: `git remote rename` does not work when `refs/remotes/server/HEAD` is unborn (when right after `git remote add -m`)

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 25, 2025, 08:00 UTC
Message-ID
<aIM5t3NMk9N0570v@pks.im>
In-Reply-To
<xmqqbjp9h1sk.fsf@gitster.g>
On Thu, Jul 24, 2025 at 11:38:35AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
[snip]
Show 28 quoted lines
> > +	if (flags & REF_ISSYMREF) {
> > +		strbuf_addstr(&new_referent, referent);
> > +		strbuf_splice(&new_referent, strlen("refs/remotes/"), strlen(rename->old_name),
> > +			      rename->new_name, strlen(rename->new_name));
> > +		oid = NULL;
> > +	}
> > +
> > +	error = ref_transaction_delete(rename->transaction, refname,
> > +				       oid, referent, REF_NO_DEREF, NULL, rename->err);
> 
> Remove old ...
> 
> > +	if (error < 0)
> > +		goto out;
> > +
> > +	strbuf_reset(&new_refname);
> > +	strbuf_addstr(&new_refname, refname);
> > +	strbuf_splice(&new_refname, strlen("refs/remotes/"), strlen(rename->old_name),
> > +		      rename->new_name, strlen(rename->new_name));
> > +
> > +	error = ref_transaction_update(rename->transaction, new_refname.buf, oid,
> > +				       null_oid(the_hash_algo), (flags & REF_ISSYMREF) ? new_referent.buf : NULL, NULL,
> > +				       REF_SKIP_CREATE_REFLOG | REF_NO_DEREF | REF_SKIP_OID_VERIFICATION,
> > +				       NULL, rename->err);
> 
> ... and create new.  Would we be hit with the same "while renaming A
> to A/B, there is a D/F conflict which the ref transaction does not
> handle by itself" issue we saw recently here?

Yes, we do indeed. I've now split this up into two transactions that get populated concurrently.

Patrick
Previous: Junio C HamanoNext: Jeff King
Message 6 of 10 in “`git remote rename` does not work when `refs/remotes/server/HEAD` is unborn (when right after `git remote add -m`)”
  1. Han JiangJul 24, 2025
  2. Jeff KingJul 24, 2025
  3. Patrick SteinhardtJul 24, 2025
  4. Patrick SteinhardtJul 24, 2025
  5. Junio C HamanoJul 24, 2025
  6. Patrick SteinhardtJul 25, 2025
  7. Jeff KingJul 25, 2025
  8. Jeff KingJul 25, 2025
  9. Patrick SteinhardtJul 28, 2025
  10. Patrick SteinhardtJul 28, 2025

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.