summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2014-11-26 10:12:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-11-26 18:51:05 (GMT)
commit61e704e38a4c3e181403a766c5cf28814e4102e4 (patch)
treedcdcecd97b02ec93f34a6b54a4f8ce1e091fc428 /sha1_name.c
parent2f93541d88fadd1ff5307d81c2c8921ee3eea058 (diff)
downloadgit-61e704e38a4c3e181403a766c5cf28814e4102e4.zip
git-61e704e38a4c3e181403a766c5cf28814e4102e4.tar.gz
git-61e704e38a4c3e181403a766c5cf28814e4102e4.tar.bz2
sha1_name: avoid unnecessary sha1 lookup in find_unique_abbrev
An example where this happens is when doing an ls-tree on a tree that contains a commit link. In that case, find_unique_abbrev is called to get a non-abbreviated hex sha1, but still, a lookup is done as to whether the sha1 is in the repository (which ends up looking for a loose object in .git/objects), while the result of that lookup is not used when returning a non-abbreviated hex sha1. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 65ad066..e98d030 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -373,10 +373,10 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
int status, exists;
static char hex[41];
- exists = has_sha1_file(sha1);
memcpy(hex, sha1_to_hex(sha1), 40);
if (len == 40 || !len)
return hex;
+ exists = has_sha1_file(sha1);
while (len < 40) {
unsigned char sha1_ret[20];
status = get_short_sha1(hex, len, sha1_ret, GET_SHA1_QUIETLY);