Merge branch 'jk/report-fail-to-read-objects-better'
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:06:15 +0000 (10:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:06:15 +0000 (10:06 -0700)
* jk/report-fail-to-read-objects-better:
open_sha1_file: report "most interesting" errno

sha1_file.c
index 3e9f55f1bb19a33908be174b2fa463f8142d4cae..34d527f6708fe242f75b7fa0fa98e36a5c96a3be 100644 (file)
@@ -1437,19 +1437,23 @@ static int open_sha1_file(const unsigned char *sha1)
 {
        int fd;
        struct alternate_object_database *alt;
+       int most_interesting_errno;
 
        fd = git_open_noatime(sha1_file_name(sha1));
        if (fd >= 0)
                return fd;
+       most_interesting_errno = errno;
 
        prepare_alt_odb();
-       errno = ENOENT;
        for (alt = alt_odb_list; alt; alt = alt->next) {
                fill_sha1_path(alt->name, sha1);
                fd = git_open_noatime(alt->base);
                if (fd >= 0)
                        return fd;
+               if (most_interesting_errno == ENOENT)
+                       most_interesting_errno = errno;
        }
+       errno = most_interesting_errno;
        return -1;
 }