Merge branch 'db/show-ref-head'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:23:56 +0000 (11:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:23:56 +0000 (11:23 -0700)
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

1  2 
Documentation/git-show-ref.txt
builtin/show-ref.c
index de4d352da2e4835c107d5dc0121e70f132ffbd34,8a628995cfca08b324f6bf1cf52037af31507bdf..b0a309b117bd12170ccd9194d1cf5083d5675365
@@@ -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[=<n>]::
  
 -      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 4a0310da371cfc851bf1d9b763a927764be68476,099c2a45577166748ceb6438e3c4a838f4b3cba3..87806ad5b088f5c905757a4fab3c3499ec20a308
@@@ -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"),