path: root/sha1_name.c
diff options
authorJunio C Hamano <>2017-11-06 05:24:28 (GMT)
committerJunio C Hamano <>2017-11-06 05:24:28 (GMT)
commit5a74ce22e61ce0c8d7325b891ef1a926cf4f6154 (patch)
tree7c4c6d967be2268e7163e861f44c493642af42a8 /sha1_name.c
parentf113d4bc799d4d0b751761db7d3760fcb9ba2c1a (diff)
parent89dd32aedcb52a77240f3923a687edc8a61662e7 (diff)
Merge branch 'jc/check-ref-format-oor'
"git check-ref-format --branch @{-1}" bit a "BUG()" when run outside a repository for obvious reasons; clarify the documentation and make sure we do not even try to expand the at-mark magic in such a case, but still call the validation logic for branch names. * jc/check-ref-format-oor: check-ref-format doc: --branch validates and expands <branch> check-ref-format --branch: strip refs/heads/ using skip_prefix check-ref-format --branch: do not expand @{...} outside repository
Diffstat (limited to 'sha1_name.c')
1 files changed, 4 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index f3b53f2..9a2d5ca 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1434,7 +1434,10 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
- strbuf_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
+ if (startup_info->have_repository)
+ strbuf_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
+ else
+ strbuf_addstr(sb, name);
if (name[0] == '-')
return -1;
strbuf_splice(sb, 0, 0, "refs/heads/", 11);