Skip to content

Commit

Permalink
Merge branch 'cb/open-noatime-clear-errno'
Browse files Browse the repository at this point in the history
When trying to see that an object does not exist, a state errno
leaked from our "first try to open a packfile with O_NOATIME and
then if it fails retry without it" logic on a system that refuses
O_NOATIME.  This confused us and caused us to die, saying that the
packfile is unreadable, when we should have just reported that the
object does not exist in that packfile to the caller.

* cb/open-noatime-clear-errno:
  git_open_noatime: return with errno=0 on success
  • Loading branch information
Junio C Hamano committed Aug 25, 2015
2 parents db86e61 + dff6f28 commit 9b8d731
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,10 @@ int git_open_noatime(const char *name)
static int sha1_file_open_flag = O_NOATIME;

for (;;) {
int fd = open(name, O_RDONLY | sha1_file_open_flag);
int fd;

errno = 0;
fd = open(name, O_RDONLY | sha1_file_open_flag);
if (fd >= 0)
return fd;

Expand Down

0 comments on commit 9b8d731

Please sign in to comment.