Re: [PATCH] git-branch: deleting remote branches in new layout
From: Junio C Hamano <hidden>
Date: 2016-08-11 20:15:36
Quy Tonthat [off-list ref] writes:
Now that remote branches are in refs/remotes/, branch -D needs to know where to find them. Signed-off-by: Quy Tonthat <redacted>
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?
+ 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)").