Previously, when --verify was specified, --head was being ignored, and "show-ref --verify --head HEAD" would always print "fatal: 'HEAD' - not a valid ref". As such, when using show-ref to look up any ref (including HEAD) precisely by name, one would have to special-case looking up the HEAD ref. This patch adds --head support to show-ref's --verify logic, by explicitly checking if the "HEAD" ref is specified when --head is present. Signed-off-by: Vladimir Panteleev <git@xxxxxxxxxxxxxxxxxx> --- builtin/show-ref.c | 2 ++ t/t1403-show-ref.sh | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 6d4e66900..ee5078604 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -207,6 +207,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) if (!quiet) show_one(*pattern, &oid); } + else if (show_head && !strcmp(*pattern, "HEAD")) + head_ref(show_ref, NULL); else if (!quiet) die("'%s' - not a valid ref", *pattern); else diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 7e10bcfe3..de64ebfb7 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -164,4 +164,12 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' ' test_cmp expect actual ' +test_expect_success 'show-ref --verify --head' ' + { + echo $(git rev-parse HEAD) HEAD + } >expect && + git show-ref --verify --head HEAD >actual && + test_cmp expect actual +' + test_done -- 2.11.0