Skip to content

Commit d90fe06

Browse files
peffgitster
authored andcommitted
pack-bitmap: refuse to do a bitmap traversal with pathspecs
rev-list has refused to use bitmaps with pathspec limiting since c8a70d3 (rev-list: disable --use-bitmap-index when pruning commits, 2015-07-01). But this is true not just for rev-list, but for anyone who calls prepare_bitmap_walk(); the code isn't equipped to handle this case. We never noticed because the only other callers would never pass a pathspec limiter. But let's push the check down into prepare_bitmap_walk() anyway. That's a more logical place for it to live, as callers shouldn't need to know the details (and must be prepared to fall back to a regular traversal anyway, since there might not be bitmaps in the repository). It would also prepare us for a day where this case _is_ handled, but that's pretty unlikely. E.g., we could use bitmaps to generate the set of commits, and then diff each commit to see if it matches the pathspec. That would be slightly faster than a naive traversal that actually walks the commits. But you'd probably do better still to make use of the newer commit-graph feature to make walking the commits very cheap. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e03f928 commit d90fe06

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
533533
if (show_progress)
534534
progress = start_delayed_progress(show_progress, 0);
535535

536-
if (use_bitmap_index && !revs.prune) {
536+
if (use_bitmap_index) {
537537
if (revs.count && !revs.left_right && !revs.cherry_mark) {
538538
uint32_t commit_count;
539539
int max_count = revs.max_count;

pack-bitmap.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,19 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
715715
struct bitmap *wants_bitmap = NULL;
716716
struct bitmap *haves_bitmap = NULL;
717717

718-
struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
718+
struct bitmap_index *bitmap_git;
719+
720+
/*
721+
* We can't do pathspec limiting with bitmaps, because we don't know
722+
* which commits are associated with which object changes (let alone
723+
* even which objects are associated with which paths).
724+
*/
725+
if (revs->prune)
726+
return NULL;
727+
719728
/* try to open a bitmapped pack, but don't parse it yet
720729
* because we may not need to use it */
730+
bitmap_git = xcalloc(1, sizeof(*bitmap_git));
721731
if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
722732
goto cleanup;
723733

0 commit comments

Comments
 (0)