{"thread":{"id":"8322","subject":"[PATCH 3/3] Attempt to delay prepare_alt_odb during get_sha1","startedAt":"2007-05-26T05:25:11Z","lastAt":"2007-05-26T05:25:11Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"43326","messageId":"20070526052511.GC11957@spearce.org","threadId":"8322","inReplyTo":null,"subject":"[PATCH 3/3] Attempt to delay prepare_alt_odb during get_sha1","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-26T05:25:11Z","receivedAt":"2007-05-26T05:25:11Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Not every input value passed to get_sha1 is an abbreviated SHA-1.\nIts actually quite common for refs to be passed and for those\nrefs to resolve to full SHA-1s, in which case we may not need to\ninitialize the alternate object database list in this process.\n\nI'm relocating the call to prepare_alt_odb closer to the code\nthat actually needs it to maintain the fix first introduced by\nJunio in 99a19b43 (to avoid ambiguous SHA-1 abbreviations from\nbeing accepted).  This allows us to avoid the alt_odb list setup\nif we won't actually need it.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n sha1_name.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 55f25a2..8dfceb2 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -133,6 +133,7 @@ static int find_unique_short_object(int len, char *canonical,\n \tint has_unpacked, has_packed;\n \tunsigned char unpacked_sha1[20], packed_sha1[20];\n \n+\tprepare_alt_odb();\n \thas_unpacked = find_short_object_filename(len, canonical, unpacked_sha1);\n \thas_packed = find_short_packed_object(len, res, packed_sha1);\n \tif (!has_unpacked && !has_packed)\n@@ -654,7 +655,6 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)\n \tconst char *cp;\n \n \t*mode = S_IFINVALID;\n-\tprepare_alt_odb();\n \tret = get_sha1_1(name, namelen, sha1);\n \tif (!ret)\n \t\treturn ret;\n-- \n1.5.2.789.g8ee1\n"}]}