for-each-ref: fix objectname:short bug

When objectname:short was introduced, it forgot to copy the result of
find_unique_abbrev. Because the result of find_unique_abbrev is a
pointer to static buffer, this resulted in the same value being
substituted in for each ref.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jay Soffian 2010-08-26 17:34:29 -04:00 committed by Junio C Hamano
parent 2244eab01b
commit ea16a030aa

View file

@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
v->s = s;
}
else if (!strcmp(name, "objectname:short")) {
v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
v->s = xstrdup(find_unique_abbrev(obj->sha1,
DEFAULT_ABBREV));
}
}
}