mirror of
https://github.com/git/git.git
synced 2024-11-24 18:33:43 +08:00
Merge branch 'kn/ref-filter-branch-list' into maint
"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
This commit is contained in:
commit
fd8567c990
16
ref-filter.c
16
ref-filter.c
@ -93,6 +93,7 @@ static struct used_atom {
|
||||
unsigned int length;
|
||||
} objectname;
|
||||
struct refname_atom refname;
|
||||
char *head;
|
||||
} u;
|
||||
} *used_atom;
|
||||
static int used_atom_cnt, need_tagged, need_symref;
|
||||
@ -287,6 +288,12 @@ static void if_atom_parser(struct used_atom *atom, const char *arg)
|
||||
}
|
||||
}
|
||||
|
||||
static void head_atom_parser(struct used_atom *atom, const char *arg)
|
||||
{
|
||||
unsigned char unused[GIT_SHA1_RAWSZ];
|
||||
|
||||
atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, unused, NULL);
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
@ -325,7 +332,7 @@ static struct {
|
||||
{ "push", FIELD_STR, remote_ref_atom_parser },
|
||||
{ "symref", FIELD_STR, refname_atom_parser },
|
||||
{ "flag" },
|
||||
{ "HEAD" },
|
||||
{ "HEAD", FIELD_STR, head_atom_parser },
|
||||
{ "color", FIELD_STR, color_atom_parser },
|
||||
{ "align", FIELD_STR, align_atom_parser },
|
||||
{ "end" },
|
||||
@ -1373,12 +1380,7 @@ static void populate_value(struct ref_array_item *ref)
|
||||
} else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
|
||||
continue;
|
||||
} else if (!strcmp(name, "HEAD")) {
|
||||
const char *head;
|
||||
unsigned char sha1[20];
|
||||
|
||||
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
|
||||
sha1, NULL);
|
||||
if (head && !strcmp(ref->refname, head))
|
||||
if (atom->u.head && !strcmp(ref->refname, atom->u.head))
|
||||
v->s = "*";
|
||||
else
|
||||
v->s = " ";
|
||||
|
Loading…
Reference in New Issue
Block a user