Skip to content

Commit

Permalink
Merge branch 'ew/repack-with-bitmaps-by-default'
Browse files Browse the repository at this point in the history
The connectivity bitmaps are created by default in bare
repositories now; also the pathname hash-cache is created by
default to avoid making crappy deltas when repacking.

* ew/repack-with-bitmaps-by-default:
  pack-objects: default to writing bitmap hash-cache
  t5310: correctly remove bitmaps for jgit test
  repack: enable bitmaps by default on bare repos
  • Loading branch information
gitster committed May 13, 2019
2 parents 5b51f0d + d431660 commit 2bfb182
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
4 changes: 1 addition & 3 deletions Documentation/config/pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,4 @@ pack.writeBitmapHashCache::
bitmapped and non-bitmapped objects (e.g., when serving a fetch
between an older, bitmapped pack and objects that have been
pushed since the last gc). The downside is that it consumes 4
bytes per object of disk space, and that JGit's bitmap
implementation does not understand it, causing it to complain if
Git and JGit are used on the same repository. Defaults to false.
bytes per object of disk space. Defaults to true.
2 changes: 1 addition & 1 deletion Documentation/config/repack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ repack.writeBitmaps::
packs created for clones and fetches, at the cost of some disk
space and extra time spent on the initial repack. This has
no effect if multiple packfiles are created.
Defaults to false.
Defaults to true on bare repos, false otherwise.
2 changes: 1 addition & 1 deletion builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static off_t reuse_packfile_offset;
static int use_bitmap_index_default = 1;
static int use_bitmap_index = -1;
static int write_bitmap_index;
static uint16_t write_bitmap_options;
static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE;

static int exclude_promisor_objects;

Expand Down
5 changes: 4 additions & 1 deletion builtin/repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

static int delta_base_offset = 1;
static int pack_kept_objects = -1;
static int write_bitmaps;
static int write_bitmaps = -1;
static int use_delta_islands;
static char *packdir, *packtmp;

Expand Down Expand Up @@ -343,6 +343,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
die(_("--keep-unreachable and -A are incompatible"));

if (write_bitmaps < 0)
write_bitmaps = (pack_everything & ALL_INTO_ONE) &&
is_bare_repository();
if (pack_kept_objects < 0)
pack_kept_objects = write_bitmaps;

Expand Down
3 changes: 1 addition & 2 deletions t/perf/p5310-pack-bitmaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ test_perf_large_repo
# We intentionally use the deprecated pack.writebitmaps
# config so that we can test against older versions of git.
test_expect_success 'setup bitmap config' '
git config pack.writebitmaps true &&
git config pack.writebitmaphashcache true
git config pack.writebitmaps true
'

test_perf 'repack to disk' '
Expand Down
1 change: 0 additions & 1 deletion t/perf/p5311-pack-bitmaps-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ test_perf_default_repo

test_expect_success 'create bitmapped server repo' '
git config pack.writebitmaps true &&
git config pack.writebitmaphashcache true &&
git repack -ad
'

Expand Down
5 changes: 2 additions & 3 deletions t/t5310-pack-bitmaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ test_expect_success 'setup repo with moderate-sized history' '
bitmaptip=$(git rev-parse master) &&
blob=$(echo tagged-blob | git hash-object -w --stdin) &&
git tag tagged-blob $blob &&
git config repack.writebitmaps true &&
git config pack.writebitmaphashcache true
git config repack.writebitmaps true
'

test_expect_success 'full repack creates bitmaps' '
Expand Down Expand Up @@ -269,7 +268,7 @@ test_expect_success JGIT 'we can read jgit bitmaps' '
git clone --bare . compat-jgit.git &&
(
cd compat-jgit.git &&
rm -f .git/objects/pack/*.bitmap &&
rm -f objects/pack/*.bitmap &&
jgit gc &&
git rev-list --test-bitmap HEAD
)
Expand Down
19 changes: 18 additions & 1 deletion t/t7700-repack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,22 @@ test_expect_success 'repack --keep-pack' '
)
'

test_done
test_expect_success 'bitmaps are created by default in bare repos' '
git clone --bare .git bare.git &&
git -C bare.git repack -ad &&
bitmap=$(ls bare.git/objects/pack/*.bitmap) &&
test_path_is_file "$bitmap"
'

test_expect_success 'incremental repack does not complain' '
git -C bare.git repack -q 2>repack.err &&
test_must_be_empty repack.err
'

test_expect_success 'bitmaps can be disabled on bare repos' '
git -c repack.writeBitmaps=false -C bare.git repack -ad &&
bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) &&
test -z "$bitmap"
'

test_done

0 comments on commit 2bfb182

Please sign in to comment.