Skip to content

Commit ea16a03

Browse files
jaysoffiangitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2244eab commit ea16a03

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/for-each-ref.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
228228
v->s = s;
229229
}
230230
else if (!strcmp(name, "objectname:short")) {
231-
v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
231+
v->s = xstrdup(find_unique_abbrev(obj->sha1,
232+
DEFAULT_ABBREV));
232233
}
233234
}
234235
}

0 commit comments

Comments
 (0)