]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/disable-pack-reuse-when-broken' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 4 Jun 2017 01:21:02 +0000 (10:21 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 4 Jun 2017 01:21:02 +0000 (10:21 +0900)
"pack-objects" can stream a slice of an existing packfile out when
the pack bitmap can tell that the reachable objects are all needed
in the output, without inspecting individual objects.  This
strategy however would not work well when "--local" and other
options are in use, and need to be disabled.

* jk/disable-pack-reuse-when-broken:
  t5310: fix "; do" style
  pack-objects: disable pack reuse for object-selection options

builtin/pack-objects.c
t/t5310-pack-bitmaps.sh

index 0fe35d1b5aebd74116d66d5414bdabf19baf7d97..50e01aa80ec7f56b32d47e841e1548c174501bc2 100644 (file)
@@ -2717,7 +2717,11 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
  */
 static int pack_options_allow_reuse(void)
 {
-       return pack_to_stdout && allow_ofs_delta;
+       return pack_to_stdout &&
+              allow_ofs_delta &&
+              !ignore_packed_keep &&
+              (!local || !have_non_local_packs) &&
+              !incremental;
 }
 
 static int get_object_list_from_bitmap(struct rev_info *revs)
index 424bec7d77c2b3761669230bf30030883ce4c230..20e2473a03b645d690b25598bc0cb2e421034b6c 100755 (executable)
@@ -20,11 +20,13 @@ has_any () {
 }
 
 test_expect_success 'setup repo with moderate-sized history' '
-       for i in $(test_seq 1 10); do
+       for i in $(test_seq 1 10)
+       do
                test_commit $i
        done &&
        git checkout -b other HEAD~5 &&
-       for i in $(test_seq 1 10); do
+       for i in $(test_seq 1 10)
+       do
                test_commit side-$i
        done &&
        git checkout master &&
@@ -104,7 +106,8 @@ test_expect_success 'clone from bitmapped repository' '
 '
 
 test_expect_success 'setup further non-bitmapped commits' '
-       for i in $(test_seq 1 10); do
+       for i in $(test_seq 1 10)
+       do
                test_commit further-$i
        done
 '
@@ -289,4 +292,43 @@ test_expect_success 'splitting packs does not generate bogus bitmaps' '
        git -C no-bitmaps.git fetch .. HEAD
 '
 
+test_expect_success 'set up reusable pack' '
+       rm -f .git/objects/pack/*.keep &&
+       git repack -adb &&
+       reusable_pack () {
+               git for-each-ref --format="%(objectname)" |
+               git pack-objects --delta-base-offset --revs --stdout "$@"
+       }
+'
+
+test_expect_success 'pack reuse respects --honor-pack-keep' '
+       test_when_finished "rm -f .git/objects/pack/*.keep" &&
+       for i in .git/objects/pack/*.pack
+       do
+               >${i%.pack}.keep
+       done &&
+       reusable_pack --honor-pack-keep >empty.pack &&
+       git index-pack empty.pack &&
+       >expect &&
+       git show-index <empty.idx >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'pack reuse respects --local' '
+       mv .git/objects/pack/* alt.git/objects/pack/ &&
+       test_when_finished "mv alt.git/objects/pack/* .git/objects/pack/" &&
+       reusable_pack --local >empty.pack &&
+       git index-pack empty.pack &&
+       >expect &&
+       git show-index <empty.idx >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'pack reuse respects --incremental' '
+       reusable_pack --incremental >empty.pack &&
+       git index-pack empty.pack &&
+       >expect &&
+       git show-index <empty.idx >actual &&
+       test_cmp expect actual
+'
 test_done