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

Re: [PATCHv2 1/2] remote: write correct fetch spec when renaming remote 'remote'

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2011, 22:58 UTC
Message-ID
<7vaaah6zx0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1314924634-12235-1-git-send-email-martin.von.zweigbergk@gmail.com>
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:
Show 22 quoted lines
> @@ -659,15 +660,18 @@ static int mv(int argc, const char **argv)
>  	strbuf_addf(&buf, "remote.%s.fetch", rename.new);
>  	if (git_config_set_multivar(buf.buf, NULL, NULL, 1))
>  		return error("Could not remove config section '%s'", buf.buf);
> +	strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
>  	for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
>  		char *ptr;
>  
>  		strbuf_reset(&buf2);
>  		strbuf_addstr(&buf2, oldremote->fetch_refspec[i]);
> -		ptr = strstr(buf2.buf, rename.old);
> +		ptr = strstr(buf2.buf, old_remote_context.buf);
>  		if (ptr)
> -			strbuf_splice(&buf2, ptr-buf2.buf, strlen(rename.old),
> -					rename.new, strlen(rename.new));
> +			strbuf_splice(&buf2,
> +				      ptr-buf2.buf + strlen(":refs/remotes/"),
> +				      strlen(rename.old), rename.new,
> +				      strlen(rename.new));
>  		if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
>  			return error("Could not append '%s'", buf.buf);
>  	}

It is somewhat bothering that we do not say "we didn't do any magic" here when we did not move the tracking branch specifications, but that is not a new problem, so I am OK with this change.

I however suspect that you would want to keep the record of what you changed here, so that the renaming of actual refs done in [PATCH 2/2] is limited to those that you updated the specifications for, no?

Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 5 of 10 in “[PATCHv2 1/2] remote: write correct fetch spec when renaming remote 'remote'”
  1. Martin von ZweigbergkSep 2, 2011
  2. 2/2 remote: "rename o foo" should not rename ref "origin/bar"Martin von Zweigbergk, Sep 2, 2011
  3. Jeff KingSep 2, 2011
  4. 3/2 remote rename: warn when refspec was not updatedMartin von Zweigbergk, Sep 3, 2011
  5. Junio C HamanoSep 6, 2011
  6. Martin von ZweigbergkSep 8, 2011
  7. Junio C HamanoSep 8, 2011
  8. Martin von ZweigbergkSep 8, 2011
  9. Junio C HamanoSep 8, 2011
  10. 4/2 remote: only update remote-tracking branch if updating refspecMartin von Zweigbergk, Sep 10, 2011

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.