Merge branch 'jc/check-ref-format-oor' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Nov 2017 03:04:57 +0000 (12:04 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Nov 2017 03:04:57 +0000 (12:04 +0900)
"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

1  2 
builtin/check-ref-format.c
sha1_name.c
index 6c40ff110bee7387d4eb4e9c7c04a21e8b12ca44,737e5ecba3158cc133dacf0dc90409070aa955fa..bc67d3f0a83d35b2fc6d81f28c6908075564644a
@@@ -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;
  }
  
diff --cc sha1_name.c
Simple merge