]> git.neil.brown.name Git - git.git/commitdiff
Merge branch 'kn/ref-filter-branch-list'
authorJunio C Hamano <gitster@pobox.com>
Mon, 29 May 2017 03:34:50 +0000 (12:34 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 May 2017 03:34:51 +0000 (12:34 +0900)
"git for-each-ref --format=..." with %(HEAD) in the format used to
resolve the HEAD symref as many times as it had processed refs,
which was wasteful, and "git branch" shared the same problem.

* kn/ref-filter-branch-list:
  ref-filter: resolve HEAD when parsing %(HEAD) atom

1  2 
ref-filter.c

diff --cc ref-filter.c
index 6cc93dcd9f54ca4fad6f68b337e1f96b7c27996b,f4c68237275d49af3f1665f40788bc8287e3f879..3742abbf85ce4044641bc937a70504c059ed8822
@@@ -287,6 -287,12 +288,12 @@@ static void if_atom_parser(struct used_
        }
  }
  
 -      unsigned char unused[GIT_SHA1_RAWSZ];
+ static void head_atom_parser(struct used_atom *atom, const char *arg)
+ {
 -      atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused, NULL);
++      struct object_id unused;
++      atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused.hash, NULL);
+ }
  
  static struct {
        const char *name;
@@@ -1366,15 -1370,10 +1373,10 @@@ static void populate_value(struct ref_a
                                v->s = xstrdup(buf + 1);
                        }
                        continue;
 -              } else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
 +              } else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
                        continue;
                } else if (!strcmp(name, "HEAD")) {
-                       const char *head;
-                       struct object_id oid;
-                       head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
-                                                 oid.hash, NULL);
-                       if (head && !strcmp(ref->refname, head))
+                       if (atom->u.head && !strcmp(ref->refname, atom->u.head))
                                v->s = "*";
                        else
                                v->s = " ";