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

Re: [PATCH] git-branch: deleting remote branches in new layout

From
Junio C Hamano <junkio@cox.net>
Date
Dec 18, 2006, 07:08 UTC
Message-ID
<7vbqm13cm0.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<45863044.4040406@gmail.com>
Quy Tonthat <qtonthat@gmail.com> writes:
> Now that remote branches are in refs/remotes/, branch -D needs to know
> where to find them.
>
> Signed-off-by: Quy Tonthat <qtonthat@gmail.com>

I recognize that giving end users a way to remove a "remote tracking branch" might be a worthy goal ("update-ref -d" _could_ be used, but "branch -D" feels more natural).

> +	char ** s;
> +	static char * branches_dir[] = {"refs/heads", "refs/remotes", NULL};
But I do not like these two entries in branches_dir[].
(style: lose SP after '*' in these two lines, by the way).

If you had refs/heads/$X and refs/remotes/$X, I do not think this code allows you to disambiguate. You cannot remove "remote" one without first removing the local one, can you?

Show 7 quoted lines
> +		for (s = branches_dir; *s != NULL; s++) {
> +			name = xstrdup(mkpath("%s/%s", *s, argv[i]));
> +			if (resolve_ref(name, sha1, 1, NULL))
> +				break;
> +		}
> +		if (*s == NULL)
>  			die("Branch '%s' not found.", argv[i]);
(style: we seem to prefer "if (!*s)").
Previous: Quy TonthatNext: Junio C Hamano
Message 2 of 6 in “git-branch: deleting remote branches in new layout”
  1. git-branch: deleting remote branches in new layoutQuy Tonthat, Dec 18, 2006
  2. Junio C HamanoDec 18, 2006
  3. Junio C HamanoDec 18, 2006
  4. Quy TonthatDec 18, 2006
  5. Quy TonthatDec 18, 2006
  6. Quy TonthatDec 18, 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.