提交 c167b76a 编写于 作者: J Junio C Hamano

Merge branch 'jk/for-each-ref-skip-parsing'

* jk/for-each-ref-skip-parsing:
  for-each-ref: avoid loading objects to print %(objectname)
......@@ -205,6 +205,22 @@ static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned lo
return buf;
}
static int grab_objectname(const char *name, const unsigned char *sha1,
struct atom_value *v)
{
if (!strcmp(name, "objectname")) {
char *s = xmalloc(41);
strcpy(s, sha1_to_hex(sha1));
v->s = s;
return 1;
}
if (!strcmp(name, "objectname:short")) {
v->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
return 1;
}
return 0;
}
/* See grab_values */
static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
{
......@@ -225,15 +241,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
v->ul = sz;
v->s = s;
}
else if (!strcmp(name, "objectname")) {
char *s = xmalloc(41);
strcpy(s, sha1_to_hex(obj->sha1));
v->s = s;
}
else if (!strcmp(name, "objectname:short")) {
v->s = xstrdup(find_unique_abbrev(obj->sha1,
DEFAULT_ABBREV));
}
else if (deref)
grab_objectname(name, obj->sha1, v);
}
}
......@@ -676,6 +685,8 @@ static void populate_value(struct refinfo *ref)
}
continue;
}
else if (!deref && grab_objectname(name, ref->objectname, v))
continue;
else
continue;
......
......@@ -58,6 +58,8 @@ test_atom head parent ''
test_atom head numparent 0
test_atom head object ''
test_atom head type ''
test_atom head '*objectname' ''
test_atom head '*objecttype' ''
test_atom head author 'A U Thor <author@example.com> 1151939924 +0200'
test_atom head authorname 'A U Thor'
test_atom head authoremail '<author@example.com>'
......@@ -91,6 +93,8 @@ test_atom tag parent ''
test_atom tag numparent ''
test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581'
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 ''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册