Skip to content

Commit a1b8e5e

Browse files
committed
Merge branch 'tl/pack-bitmap-absolute-paths'
The pack-bitmap machinery is taught to log the paths of redundant bitmap(s) to trace2 instead of stderr. * tl/pack-bitmap-absolute-paths: pack-bitmap.c: trace bitmap ignore logs when midx-bitmap is found pack-bitmap.c: break out of the bitmap loop early if not tracing pack-bitmap.c: avoid exposing absolute paths pack-bitmap.c: remove unnecessary "open_pack_index()" calls
2 parents 06ae40f + c8f4357 commit a1b8e5e

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

pack-bitmap.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
354354
if (bitmap_git->pack || bitmap_git->midx) {
355355
struct strbuf buf = STRBUF_INIT;
356356
get_midx_filename(&buf, midx->object_dir);
357-
/* ignore extra bitmap file; we can only handle one */
358-
warning(_("ignoring extra bitmap file: '%s'"), buf.buf);
357+
trace2_data_string("bitmap", the_repository,
358+
"ignoring extra midx bitmap file", buf.buf);
359359
close(fd);
360360
strbuf_release(&buf);
361361
return -1;
@@ -411,9 +411,6 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
411411
struct stat st;
412412
char *bitmap_name;
413413

414-
if (open_pack_index(packfile))
415-
return -1;
416-
417414
bitmap_name = pack_bitmap_filename(packfile);
418415
fd = git_open(bitmap_name);
419416

@@ -432,8 +429,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
432429
}
433430

434431
if (bitmap_git->pack || bitmap_git->midx) {
435-
/* ignore extra bitmap file; we can only handle one */
436-
warning(_("ignoring extra bitmap file: '%s'"), packfile->pack_name);
432+
trace2_data_string("bitmap", the_repository,
433+
"ignoring extra bitmap file", packfile->pack_name);
437434
close(fd);
438435
return -1;
439436
}
@@ -458,6 +455,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
458455
return -1;
459456
}
460457

458+
trace2_data_string("bitmap", the_repository, "opened bitmap file",
459+
packfile->pack_name);
461460
return 0;
462461
}
463462

@@ -525,11 +524,16 @@ static int open_pack_bitmap(struct repository *r,
525524
struct packed_git *p;
526525
int ret = -1;
527526

528-
assert(!bitmap_git->map);
529-
530527
for (p = get_all_packs(r); p; p = p->next) {
531-
if (open_pack_bitmap_1(bitmap_git, p) == 0)
528+
if (open_pack_bitmap_1(bitmap_git, p) == 0) {
532529
ret = 0;
530+
/*
531+
* The only reason to keep looking is to report
532+
* duplicates.
533+
*/
534+
if (!trace2_is_enabled())
535+
break;
536+
}
533537
}
534538

535539
return ret;
@@ -553,11 +557,20 @@ static int open_midx_bitmap(struct repository *r,
553557
static int open_bitmap(struct repository *r,
554558
struct bitmap_index *bitmap_git)
555559
{
560+
int found;
561+
556562
assert(!bitmap_git->map);
557563

558-
if (!open_midx_bitmap(r, bitmap_git))
559-
return 0;
560-
return open_pack_bitmap(r, bitmap_git);
564+
found = !open_midx_bitmap(r, bitmap_git);
565+
566+
/*
567+
* these will all be skipped if we opened a midx bitmap; but run it
568+
* anyway if tracing is enabled to report the duplicates
569+
*/
570+
if (!found || trace2_is_enabled())
571+
found |= !open_pack_bitmap(r, bitmap_git);
572+
573+
return found ? 0 : -1;
561574
}
562575

563576
struct bitmap_index *prepare_bitmap_git(struct repository *r)

t/t5310-pack-bitmaps.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ test_bitmap_cases () {
428428
test_line_count = 2 packs &&
429429
test_line_count = 2 bitmaps &&
430430
431-
git rev-list --use-bitmap-index HEAD 2>err &&
432-
grep "ignoring extra bitmap file" err
431+
GIT_TRACE2_EVENT=$(pwd)/trace2.txt git rev-list --use-bitmap-index HEAD &&
432+
grep "opened bitmap" trace2.txt &&
433+
grep "ignoring extra bitmap" trace2.txt
433434
)
434435
'
435436
}

0 commit comments

Comments
 (0)