Skip to content

Commit e93ec6f

Browse files
author
Junio C Hamano
committed
Revert "check_packed_git_idx(): check integrity of the idx file itself."
This reverts c5ced64 commit. It turns out that doing this check every time we map the idx file is quite expensive. A corrupt idx file is caught by git-fsck-objects, so this check is not strictly necessary. In one unscientific test, 0.99.9m spent 10 seconds usertime for the same task 1.1.3 takes 37 seconds usertime. Reverting this gives us the performance of 0.99.9 back.
1 parent ee3d299 commit e93ec6f

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

sha1_file.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,12 @@ struct packed_git *packed_git;
321321
static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
322322
void **idx_map_)
323323
{
324-
SHA_CTX ctx;
325-
unsigned char sha1[20];
326324
void *idx_map;
327325
unsigned int *index;
328326
unsigned long idx_size;
329327
int nr, i;
330-
int fd;
328+
int fd = open(path, O_RDONLY);
331329
struct stat st;
332-
333-
fd = open(path, O_RDONLY);
334330
if (fd < 0)
335331
return -1;
336332
if (fstat(fd, &st)) {
@@ -368,16 +364,6 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
368364
if (idx_size != 4*256 + nr * 24 + 20 + 20)
369365
return error("wrong index file size");
370366

371-
/*
372-
* File checksum.
373-
*/
374-
SHA1_Init(&ctx);
375-
SHA1_Update(&ctx, idx_map, idx_size-20);
376-
SHA1_Final(sha1, &ctx);
377-
378-
if (memcmp(sha1, idx_map + idx_size - 20, 20))
379-
return error("index checksum mismatch");
380-
381367
return 0;
382368
}
383369

0 commit comments

Comments
 (0)