Merge branch 'jk/interpret-branch-name' into maint
"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.
* jk/interpret-branch-name:
checkout: restrict @-expansions when finding branch
strbuf_check_ref_format(): expand only local branches
branch: restrict @-expansions when deleting
t3204: test git-branch @-expansion corner cases
interpret_branch_name: allow callers to restrict expansions
strbuf_branchname: add docstring
strbuf_branchname: drop return value
interpret_branch_name: move docstring to header file
interpret_branch_name(): handle auto-namelen for @{-1}
This commit is contained in:
@ -190,17 +190,20 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||
int ret = 0;
|
||||
int remote_branch = 0;
|
||||
struct strbuf bname = STRBUF_INIT;
|
||||
unsigned allowed_interpret;
|
||||
|
||||
switch (kinds) {
|
||||
case FILTER_REFS_REMOTES:
|
||||
fmt = "refs/remotes/%s";
|
||||
/* For subsequent UI messages */
|
||||
remote_branch = 1;
|
||||
allowed_interpret = INTERPRET_BRANCH_REMOTE;
|
||||
|
||||
force = 1;
|
||||
break;
|
||||
case FILTER_REFS_BRANCHES:
|
||||
fmt = "refs/heads/%s";
|
||||
allowed_interpret = INTERPRET_BRANCH_LOCAL;
|
||||
break;
|
||||
default:
|
||||
die(_("cannot use -a with -d"));
|
||||
@ -215,7 +218,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||
char *target = NULL;
|
||||
int flags = 0;
|
||||
|
||||
strbuf_branchname(&bname, argv[i]);
|
||||
strbuf_branchname(&bname, argv[i], allowed_interpret);
|
||||
free(name);
|
||||
name = mkpathdup(fmt, bname.buf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user