From: Junio C Hamano Date: Mon, 6 Nov 2017 05:24:28 +0000 (+0900) Subject: Merge branch 'jc/check-ref-format-oor' X-Git-Tag: v2.16.0-rc0~161 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5a74ce22e61ce0c8d7325b891ef1a926cf4f6154 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 check-ref-format --branch: strip refs/heads/ using skip_prefix check-ref-format --branch: do not expand @{...} outside repository --- 5a74ce22e61ce0c8d7325b891ef1a926cf4f6154 diff --cc builtin/check-ref-format.c index 6c40ff110b,737e5ecba3..bc67d3f0a8 --- a/builtin/check-ref-format.c +++ b/builtin/check-ref-format.c @@@ -42,10 -43,10 +43,11 @@@ static int check_ref_format_branch(cons int nongit; setup_git_directory_gently(&nongit); - if (strbuf_check_branch_ref(&sb, arg)) + if (strbuf_check_branch_ref(&sb, arg) || + !skip_prefix(sb.buf, "refs/heads/", &name)) die("'%s' is not a valid branch name", arg); - printf("%s\n", sb.buf + 11); + printf("%s\n", name); + strbuf_release(&sb); return 0; }