From: Junio C Hamano Date: Fri, 6 Dec 2013 19:07:20 +0000 (-0800) Subject: Merge branch 'rr/for-each-ref-decoration' X-Git-Tag: v1.9-rc0~85 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cb6bd5722f430b225b894920fd80975ffa1d0bb5 Merge branch 'rr/for-each-ref-decoration' 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 --- cb6bd5722f430b225b894920fd80975ffa1d0bb5 diff --cc builtin/for-each-ref.c index d096051b15,5ff51d1d32..875bd813d5 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@@ -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, ':'); diff --cc t/t6300-for-each-ref.sh index da5fb6c917,46866bab01..bda354c1c4 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@@ -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 ''