Skip to content

Commit

Permalink
write_loose_object: don't bother trying to read an old object
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Jun 17, 2008
1 parent 328a475 commit 1421c5f
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2145,20 +2145,6 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
static char tmpfile[PATH_MAX];

filename = sha1_file_name(sha1);
fd = open(filename, O_RDONLY);
if (fd >= 0) {
/*
* FIXME!!! We might do collision checking here, but we'd
* need to uncompress the old file and check it. Later.
*/
close(fd);
return 0;
}

if (errno != ENOENT) {
return error("sha1 file %s: %s\n", filename, strerror(errno));
}

fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
if (fd < 0) {
if (errno == EPERM)
Expand Down

0 comments on commit 1421c5f

Please sign in to comment.