diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-28 13:52:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-28 13:52:22 -0700 |
commit | 41534b626ebdf3fb4fb692749245b90ff2bb7e13 (patch) | |
tree | 6948d02d5cc525926a01cfa1b3434a67791a6122 /builtin | |
parent | e25c1229b2f7f12fd3284297a73bb889c8f35f63 (diff) | |
parent | fd4692ff7040e690546ed139a419995e76a96196 (diff) | |
download | git-41534b626ebdf3fb4fb692749245b90ff2bb7e13.tar.gz git-41534b626ebdf3fb4fb692749245b90ff2bb7e13.tar.xz |
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}
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/branch.c | 5 | ||||
-rw-r--r-- | builtin/checkout.c | 2 | ||||
-rw-r--r-- | builtin/merge.c | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 9d30f55b0..babfd0f73 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -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); diff --git a/builtin/checkout.c b/builtin/checkout.c index f174f5030..81f07c3ef 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -452,7 +452,7 @@ static void setup_branch_path(struct branch_info *branch) { struct strbuf buf = STRBUF_INIT; - strbuf_branchname(&buf, branch->name); + strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); if (strcmp(buf.buf, branch->name)) branch->name = xstrdup(buf.buf); strbuf_splice(&buf, 0, 0, "refs/heads/", 11); diff --git a/builtin/merge.c b/builtin/merge.c index a96d4fb50..848a29855 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -438,7 +438,7 @@ static void merge_name(const char *remote, struct strbuf *msg) char *found_ref; int len, early; - strbuf_branchname(&bname, remote); + strbuf_branchname(&bname, remote, 0); remote = bname.buf; memset(branch_head, 0, sizeof(branch_head)); |