Attempt to delay prepare_alt_odb during get_sha1
Not every input value passed to get_sha1 is an abbreviated SHA-1. Its actually quite common for refs to be passed and for those refs to resolve to full SHA-1s, in which case we may not need to initialize the alternate object database list in this process. I'm relocating the call to prepare_alt_odb closer to the code that actually needs it to maintain the fix first introduced by Junio in 99a19b43 (to avoid ambiguous SHA-1 abbreviations from being accepted). This allows us to avoid the alt_odb list setup if we won't actually need it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
May 26, 2007 at 01:25 UTC
693d2bc625e7168299741d673e7205e9d2c969df
1 file changed
+1
-1
sha1_name.c
+1
-1
@@ -133,6 +133,7 @@ static int find_unique_short_object(int len, char *canonical,
133
int has_unpacked, has_packed;
134
unsigned char unpacked_sha1[20], packed_sha1[20];
135
136
+ prepare_alt_odb();
137
has_unpacked = find_short_object_filename(len, canonical, unpacked_sha1);
138
has_packed = find_short_packed_object(len, res, packed_sha1);
139
if (!has_unpacked && !has_packed)
@@ -654,7 +655,6 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
655
const char *cp;
656
657
*mode = S_IFINVALID;
657
- prepare_alt_odb();
658
ret = get_sha1_1(name, namelen, sha1);
659
if (!ret)
660
return ret;