]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap.c: do not ignore error when opening a bitmap file
authorTeng Long <dyroneteng@gmail.com>
Mon, 18 Jul 2022 16:46:03 +0000 (00:46 +0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Jul 2022 18:20:52 +0000 (11:20 -0700)
Calls to git_open() to open the pack bitmap file and
multi-pack bitmap file do not report any error when they
fail.  These files are optional and it is not an error if
open failed due to ENOENT, but we shouldn't be ignoring
other kinds of errors.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c

index b6bf454c11fd0a9594f06305ec85c1d4f0b25075..da3df1cfec421ff0d95c6a0dfa9941dda28c9a40 100644 (file)
@@ -317,10 +317,13 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
        char *bitmap_name = midx_bitmap_filename(midx);
        int fd = git_open(bitmap_name);
 
-       free(bitmap_name);
-
-       if (fd < 0)
+       if (fd < 0) {
+               if (errno != ENOENT)
+                       warning_errno("cannot open '%s'", bitmap_name);
+               free(bitmap_name);
                return -1;
+       }
+       free(bitmap_name);
 
        if (fstat(fd, &st)) {
                close(fd);
@@ -376,10 +379,14 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
 
        bitmap_name = pack_bitmap_filename(packfile);
        fd = git_open(bitmap_name);
-       free(bitmap_name);
 
-       if (fd < 0)
+       if (fd < 0) {
+               if (errno != ENOENT)
+                       warning_errno("cannot open '%s'", bitmap_name);
+               free(bitmap_name);
                return -1;
+       }
+       free(bitmap_name);
 
        if (fstat(fd, &st)) {
                close(fd);