From: Junio C Hamano Date: Mon, 22 Jul 2013 18:23:56 +0000 (-0700) Subject: Merge branch 'db/show-ref-head' X-Git-Tag: v1.8.4-rc0~27 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d0b3fa8fd9faf5d18d54e2beb04741fff88af358?ds=inline;hp=-c 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 --- d0b3fa8fd9faf5d18d54e2beb04741fff88af358 diff --combined Documentation/git-show-ref.txt index de4d352da2,8a628995cf..b0a309b117 --- a/Documentation/git-show-ref.txt +++ b/Documentation/git-show-ref.txt @@@ -21,6 -21,8 +21,8 @@@ commit IDs. Results can be filtered usi dereferenced into object IDs. Additionally, it can be used to test whether a particular ref exists. + By default, shows the tags, heads, and remote refs. + The --exclude-existing form is a filter that does the inverse, it shows the refs from stdin that don't exist in the local repository. @@@ -32,14 -34,14 +34,14 @@@ OPTION --head:: - Show the HEAD reference. + Show the HEAD reference, even if it would normally be filtered out. --tags:: --heads:: - Limit to only "refs/heads" and "refs/tags", respectively. These - options are not mutually exclusive; when given both, references stored - in "refs/heads" and "refs/tags" are displayed. + Limit to "refs/heads" and "refs/tags", respectively. These options + are not mutually exclusive; when given both, references stored in + "refs/heads" and "refs/tags" are displayed. -d:: --dereference:: @@@ -50,8 -52,8 +52,8 @@@ -s:: --hash[=]:: - Only show the SHA1 hash, not the reference name. When combined with - --dereference the dereferenced tag will still be shown after the SHA1. + Only show the SHA-1 hash, not the reference name. When combined with + --dereference the dereferenced tag will still be shown after the SHA-1. --verify:: diff --combined builtin/show-ref.c index 4a0310da37,099c2a4557..87806ad5b0 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@@ -31,6 -31,9 +31,9 @@@ static int show_ref(const char *refname const char *hex; unsigned char peeled[20]; + if (show_head && !strcmp(refname, "HEAD")) + goto match; + if (tags_only || heads_only) { int match; @@@ -103,7 -106,7 +106,7 @@@ static int add_existing(const char *ref */ static int exclude_existing(const char *match) { - static struct string_list existing_refs = STRING_LIST_INIT_NODUP; + static struct string_list existing_refs = STRING_LIST_INIT_DUP; char buf[1024]; int matchlen = match ? strlen(match) : 0; @@@ -167,9 -170,10 +170,10 @@@ static const struct option show_ref_opt 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"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, - 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"),