Skip to content

Commit 81bd9b1

Browse files
committed
Merge branch 'jk/report-fail-to-read-objects-better' into maint
Reworded the error message given upon a failure to open an existing loose object file due to e.g. permission issues; it was reported as the object being corrupt, but that is not quite true. * jk/report-fail-to-read-objects-better: open_sha1_file: report "most interesting" errno
2 parents 73505ef + d6c8a05 commit 81bd9b1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sha1_file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,19 +1437,23 @@ static int open_sha1_file(const unsigned char *sha1)
14371437
{
14381438
int fd;
14391439
struct alternate_object_database *alt;
1440+
int most_interesting_errno;
14401441

14411442
fd = git_open_noatime(sha1_file_name(sha1));
14421443
if (fd >= 0)
14431444
return fd;
1445+
most_interesting_errno = errno;
14441446

14451447
prepare_alt_odb();
1446-
errno = ENOENT;
14471448
for (alt = alt_odb_list; alt; alt = alt->next) {
14481449
fill_sha1_path(alt->name, sha1);
14491450
fd = git_open_noatime(alt->base);
14501451
if (fd >= 0)
14511452
return fd;
1453+
if (most_interesting_errno == ENOENT)
1454+
most_interesting_errno = errno;
14521455
}
1456+
errno = most_interesting_errno;
14531457
return -1;
14541458
}
14551459

0 commit comments

Comments
 (0)