OSDN Git Service

Merge branch 'rr/for-each-ref-decoration'
authorJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2013 19:07:20 +0000 (11:07 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2013 19:07:21 +0000 (11:07 -0800)
Add a few formatting directives to "git for-each-ref --format=...",
to paint them in color, etc.

* rr/for-each-ref-decoration:
  for-each-ref: avoid color leakage
  for-each-ref: introduce %(color:...) for color
  for-each-ref: introduce %(upstream:track[short])
  for-each-ref: introduce %(HEAD) asterisk marker
  t6300 (for-each-ref): don't hardcode SHA-1 hexes
  t6300 (for-each-ref): clearly demarcate setup

1  2 
builtin/for-each-ref.c
t/t6300-for-each-ref.sh

@@@ -684,10 -692,17 +701,19 @@@ static void populate_value(struct refin
                                v->s = xstrdup(buf + 1);
                        }
                        continue;
-               }
-               else if (!deref && grab_objectname(name, ref->objectname, v))
++              } else if (!deref && grab_objectname(name, ref->objectname, v)) {
 +                      continue;
-               else
+               } else if (!strcmp(name, "HEAD")) {
+                       const char *head;
+                       unsigned char sha1[20];
+                       head = resolve_ref_unsafe("HEAD", sha1, 1, NULL);
+                       if (!strcmp(ref->refname, head))
+                               v->s = "*";
+                       else
+                               v->s = " ";
+                       continue;
+               } else
                        continue;
  
                formatp = strchr(name, ':');
@@@ -91,10 -87,8 +89,10 @@@ test_atom tag objectname $(git rev-pars
  test_atom tag tree ''
  test_atom tag parent ''
  test_atom tag numparent ''
- test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581'
+ test_atom tag object $(git rev-parse refs/tags/testtag^0)
  test_atom tag type 'commit'
 +test_atom tag '*objectname' '67a36f10722846e891fbada1ba48ed035de75581'
 +test_atom tag '*objecttype' 'commit'
  test_atom tag author ''
  test_atom tag authorname ''
  test_atom tag authoremail ''