Skip to content

Commit 1421c5f

Browse files
torvaldsgitster
authored andcommitted
write_loose_object: don't bother trying to read an old object
Before even calling this, all callers have done a "has_sha1_file(sha1)" or "has_loose_object(sha1)" check, so there is no point in doing a second check. If something races with us on object creation, we handle that in the final link() that moves it to the right place. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 328a475 commit 1421c5f

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

sha1_file.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,20 +2145,6 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
21452145
static char tmpfile[PATH_MAX];
21462146

21472147
filename = sha1_file_name(sha1);
2148-
fd = open(filename, O_RDONLY);
2149-
if (fd >= 0) {
2150-
/*
2151-
* FIXME!!! We might do collision checking here, but we'd
2152-
* need to uncompress the old file and check it. Later.
2153-
*/
2154-
close(fd);
2155-
return 0;
2156-
}
2157-
2158-
if (errno != ENOENT) {
2159-
return error("sha1 file %s: %s\n", filename, strerror(errno));
2160-
}
2161-
21622148
fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
21632149
if (fd < 0) {
21642150
if (errno == EPERM)

0 commit comments

Comments
 (0)