@matheusbsbs / matheus-bagliano / commits / 1421c5f274
Fork 0

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 <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Jun 16, 2008 at 17:17 UTC 1421c5f274a10f93ce5e8b51c0e1351905f84f4e
1 file changed -14
sha1_file.c
-14
@@ -2145,20 +2145,6 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
2145 static char tmpfile[PATH_MAX];
2146
2147 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 -
2148 fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
2149 if (fd < 0) {
2150 if (errno == EPERM)