path: root/builtin/show-ref.c
diff options
authorJunio C Hamano <>2013-07-22 18:23:56 (GMT)
committerJunio C Hamano <>2013-07-22 18:23:56 (GMT)
commitd0b3fa8fd9faf5d18d54e2beb04741fff88af358 (patch)
treebc35c4471f726637bd45ee79102dccda7c409c97 /builtin/show-ref.c
parente9682cc028e4d360dcf1364691095accc75f4b74 (diff)
parent3f3d0cea61aba6ac2fef16736ef55e04bb735e02 (diff)
Merge branch 'db/show-ref-head'
The "--head" option to "git show-ref" was only to add "HEAD" to the list of candidate refs to be filtered by the usual rules (e.g. "--heads" that only show refs under refs/heads). Change the meaning of the option to always show "HEAD" regardless of what filtering will be applied to any other ref (this is a backward incompatible change, so I may need to add an entry to the Release Notes). * db/show-ref-head: show-ref: make --head always show the HEAD ref
Diffstat (limited to 'builtin/show-ref.c')
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 4a0310d..87806ad 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -31,6 +31,9 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
const char *hex;
unsigned char peeled[20];
+ if (show_head && !strcmp(refname, "HEAD"))
+ goto match;
if (tags_only || heads_only) {
int match;
@@ -167,9 +170,10 @@ static const struct option show_ref_options[] = {
OPT_BOOLEAN(0, "verify", &verify, N_("stricter reference checking, "
"requires exact ref path")),
{ OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,
- N_("show the HEAD reference"),
+ N_("show the HEAD reference, even if it would be filtered out"),
- OPT_BOOLEAN(0, "head", &show_head, N_("show the HEAD reference")),
+ OPT_BOOLEAN(0, "head", &show_head,
+ N_("show the HEAD reference, even if it would be filtered out")),
OPT_BOOLEAN('d', "dereference", &deref_tags,
N_("dereference tags into object IDs")),
{ OPTION_CALLBACK, 's', "hash", &abbrev, N_("n"),