diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-11-01 07:38:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-11-01 07:38:41 -0700 |
commit | c167b76a6249ed0eb4bedd11c5852b2818c276f7 (patch) | |
tree | fd7f4fc5986a5733b08901118cff2d2d78b6e5c0 /builtin | |
parent | 583736c0bcf09adaa5621b142d8e43c22354041b (diff) | |
parent | b74cf648036af764a176898763a0ec066a77a92f (diff) | |
download | git-c167b76a6249ed0eb4bedd11c5852b2818c276f7.tar.gz git-c167b76a6249ed0eb4bedd11c5852b2818c276f7.tar.xz |
Merge branch 'jk/for-each-ref-skip-parsing'
* jk/for-each-ref-skip-parsing:
for-each-ref: avoid loading objects to print %(objectname)
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 1d4083c2d..d096051b1 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -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; |