Erik Faye-Lund <kusmabite@xxxxxxxxxxxxxx> writes: > Signed-off-by: Erik Faye-Lund <kusmabite@xxxxxxxxx> > --- > sha1_name.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sha1_name.c b/sha1_name.c > index bf92417..2b1be58 100644 > --- a/sha1_name.c > +++ b/sha1_name.c > @@ -196,10 +196,10 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len) > int status, exists; > static char hex[41]; > > + if (len == 40 || !len) > + return sha1_to_hex(sha1); > exists = has_sha1_file(sha1); > memcpy(hex, sha1_to_hex(sha1), 40); > - if (len == 40 || !len) > - return hex; This is somewhat iffy. hex[] being static means there can only be one outstanding return value from f-u-a being used, iow printf("%s %s", f-u-a(a, 0), f-u-a(b, 0)) is a no-no. But at the same time, it means that you can use one more recycled buffer than sha1_to_hex() gives us, so this may be safe: char *ua = f-u-a(a, 0); printf("%s %s %s %s %s", ua, sha1_to_hex(b), sha1_to_hex(c), sha1_to_hex(d), sha1_to_hex(e)); but with the above it probably is not anymore, no? As an optimization patch, I would buy that delaying the "exists" check until the "no abbreviation" check returned early would make sense, though. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html