Skip to content

Commit 6411cc0

Browse files
dyronegitster
authored andcommitted
pack-bitmap.c: do not ignore error when opening a bitmap file
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 349c26f commit 6411cc0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pack-bitmap.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,13 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
317317
char *bitmap_name = midx_bitmap_filename(midx);
318318
int fd = git_open(bitmap_name);
319319

320-
free(bitmap_name);
321-
322-
if (fd < 0)
320+
if (fd < 0) {
321+
if (errno != ENOENT)
322+
warning_errno("cannot open '%s'", bitmap_name);
323+
free(bitmap_name);
323324
return -1;
325+
}
326+
free(bitmap_name);
324327

325328
if (fstat(fd, &st)) {
326329
close(fd);
@@ -376,10 +379,14 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
376379

377380
bitmap_name = pack_bitmap_filename(packfile);
378381
fd = git_open(bitmap_name);
379-
free(bitmap_name);
380382

381-
if (fd < 0)
383+
if (fd < 0) {
384+
if (errno != ENOENT)
385+
warning_errno("cannot open '%s'", bitmap_name);
386+
free(bitmap_name);
382387
return -1;
388+
}
389+
free(bitmap_name);
383390

384391
if (fstat(fd, &st)) {
385392
close(fd);

0 commit comments

Comments
 (0)