diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-11-06 14:24:28 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-06 14:24:28 +0900 |
commit | 5a74ce22e61ce0c8d7325b891ef1a926cf4f6154 (patch) | |
tree | 7c4c6d967be2268e7163e861f44c493642af42a8 /sha1_name.c | |
parent | f113d4bc799d4d0b751761db7d3760fcb9ba2c1a (diff) | |
parent | 89dd32aedcb52a77240f3923a687edc8a61662e7 (diff) | |
download | git-5a74ce22e61ce0c8d7325b891ef1a926cf4f6154.tar.gz |
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')
-rw-r--r-- | sha1_name.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c index f3b53f2c29..9a2d5caf3b 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); |