Skip to content

Commit 13ff91f

Browse files
derrickstoleedscho
authored andcommitted
pack-objects: introduce GIT_TEST_PACK_PATH_WALK
There are many tests that validate whether 'git pack-objects' works as expected. Instead of duplicating these tests, add a new test environment variable, GIT_TEST_PACK_PATH_WALK, that implies --path-walk by default when specified. This was useful in testing the implementation of the --path-walk implementation, especially in conjunction with test such as: - t0411-clone-from-partial.sh : One test fetches from a repo that does not have the boundary objects. This causes the path-based walk to fail. Disable the variable for this test. - t5306-pack-nobase.sh : Similar to t0411, one test fetches from a repo without a boundary object. - t5310-pack-bitmaps.sh : One test compares the case when packing with bitmaps to the case when packing without them. Since we disable the test variable when writing bitmaps, this causes a difference in the object list (the --path-walk option adds an extra object). Specify --no-path-walk in both processes for the comparison. Another test checks for a specific delta base, but when computing dynamically without using bitmaps, the base object it too small to be considered in the delta calculations so no base is used. - t5316-pack-delta-depth.sh : This script cares about certain delta choices and their chain lengths. The --path-walk option changes how these chains are selected, and thus changes the results of this test. - t5322-pack-objects-sparse.sh : This demonstrates the effectiveness of the --sparse option and how it combines with --path-walk. - t5332-multi-pack-reuse.sh : This test verifies that the preferred pack is used for delta reuse when possible. The --path-walk option is not currently aware of the preferred pack at all, so finds a different delta base. - t7406-submodule-update.sh : When using the variable, the --depth option collides with the --path-walk feature, resulting in a warning message. Disable the variable so this warning does not appear. I want to call out one specific test change that is only temporary: - t5530-upload-pack-error.sh : One test cares specifically about an "unable to read" error message. Since the current implementation performs delta calculations within the path-walk API callback, a different "unable to get size" error message appears. When this is changed in a future refactoring, this test change can be reverted. Signed-off-by: Derrick Stolee <[email protected]>
1 parent 8e8a5b8 commit 13ff91f

10 files changed

+60
-7
lines changed

builtin/pack-objects.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int delta_search_threads;
218218
static int pack_to_stdout;
219219
static int sparse;
220220
static int thin;
221-
static int path_walk;
221+
static int path_walk = -1;
222222
static int num_preferred_base;
223223
static struct progress *progress_state;
224224

@@ -4184,7 +4184,7 @@ static int add_objects_by_path(const char *path,
41844184
struct object_id *oid = &oids->oid[i];
41854185

41864186
/* Skip objects that do not exist locally. */
4187-
if (exclude_promisor_objects &&
4187+
if ((exclude_promisor_objects || arg_missing_action != MA_ERROR) &&
41884188
oid_object_info_extended(the_repository, oid, &oi,
41894189
OBJECT_INFO_FOR_PREFETCH) < 0)
41904190
continue;
@@ -4587,6 +4587,14 @@ int cmd_pack_objects(int argc,
45874587
if (pack_to_stdout != !base_name || argc)
45884588
usage_with_options(pack_usage, pack_objects_options);
45894589

4590+
if (path_walk < 0) {
4591+
if (use_bitmap_index > 0 ||
4592+
!use_internal_rev_list)
4593+
path_walk = 0;
4594+
else
4595+
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
4596+
}
4597+
45904598
if (depth < 0)
45914599
depth = 0;
45924600
if (depth >= (1 << OE_DEPTH_BITS)) {

ci/run-build-and-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ linux-TEST-vars)
3131
export GIT_TEST_CHECKOUT_WORKERS=2
3232
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
3333
export GIT_TEST_FULL_NAME_HASH=1
34+
export GIT_TEST_PACK_PATH_WALK=1
3435
;;
3536
linux-clang)
3637
export GIT_TEST_DEFAULT_HASH=sha1

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ GIT_TEST_PACK_SPARSE=<boolean> if disabled will default the pack-objects
436436
builtin to use the non-sparse object walk. This can still be overridden by
437437
the --sparse command-line argument.
438438

439+
GIT_TEST_PACK_PATH_WALK=<boolean> if enabled will default the pack-objects
440+
builtin to use the path-walk API for the object walk. This can still be
441+
overridden by the --no-path-walk command-line argument.
442+
439443
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
440444
by overriding the minimum number of cache entries required per thread.
441445

t/t0411-clone-from-partial.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ test_expect_success 'pack-objects should fetch from promisor remote and execute
6363

6464
test_expect_success 'clone from promisor remote does not lazy-fetch by default' '
6565
rm -f script-executed &&
66+
67+
# The --path-walk feature of "git pack-objects" is not
68+
# compatible with this kind of fetch from an incomplete repo.
69+
GIT_TEST_PACK_PATH_WALK=0 &&
70+
export GIT_TEST_PACK_PATH_WALK &&
71+
6672
test_must_fail git clone evil no-lazy 2>err &&
6773
test_grep "lazy fetching disabled" err &&
6874
test_path_is_missing script-executed

t/t5306-pack-nobase.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ test_expect_success 'indirectly clone patch_clone' '
6060
git pull ../.git &&
6161
test $(git rev-parse HEAD) = $B &&
6262
63+
# The --path-walk feature of "git pack-objects" is not
64+
# compatible with this kind of fetch from an incomplete repo.
65+
GIT_TEST_PACK_PATH_WALK=0 &&
66+
export GIT_TEST_PACK_PATH_WALK &&
67+
6368
git pull ../patch_clone/.git &&
6469
test $(git rev-parse HEAD) = $C
6570
)

t/t5310-pack-bitmaps.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ test_bitmap_cases () {
155155
ls .git/objects/pack/ | grep bitmap >output &&
156156
test_line_count = 1 output &&
157157
# verify equivalent packs are generated with/without using bitmap index
158-
packasha1=$(git pack-objects --no-use-bitmap-index --all packa </dev/null) &&
159-
packbsha1=$(git pack-objects --use-bitmap-index --all packb </dev/null) &&
158+
# Be careful to not use the path-walk option in either case.
159+
packasha1=$(git pack-objects --no-use-bitmap-index --no-path-walk --all packa </dev/null) &&
160+
packbsha1=$(git pack-objects --use-bitmap-index --no-path-walk --all packb </dev/null) &&
160161
list_packed_objects packa-$packasha1.idx >packa.objects &&
161162
list_packed_objects packb-$packbsha1.idx >packb.objects &&
162163
test_cmp packa.objects packb.objects
@@ -385,6 +386,14 @@ test_bitmap_cases () {
385386
git init --bare client.git &&
386387
(
387388
cd client.git &&
389+
390+
# This test relies on reusing a delta, but if the
391+
# path-walk machinery is engaged, the base object
392+
# is considered too small to use during the
393+
# dynamic computation, so is not used.
394+
GIT_TEST_PACK_PATH_WALK=0 &&
395+
export GIT_TEST_PACK_PATH_WALK &&
396+
388397
git config transfer.unpackLimit 1 &&
389398
git fetch .. delta-reuse-old:delta-reuse-old &&
390399
git fetch .. delta-reuse-new:delta-reuse-new &&

t/t5316-pack-delta-depth.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ max_chain() {
9090
# adjusted (or scrapped if the heuristics have become too unreliable)
9191
test_expect_success 'packing produces a long delta' '
9292
# Use --window=0 to make sure we are seeing reused deltas,
93-
# not computing a new long chain.
94-
pack=$(git pack-objects --all --window=0 </dev/null pack) &&
93+
# not computing a new long chain. (Also avoid the --path-walk
94+
# option as it may break delta chains.)
95+
pack=$(git pack-objects --all --window=0 --no-path-walk </dev/null pack) &&
9596
echo 9 >expect &&
9697
max_chain pack-$pack.pack >actual &&
9798
test_cmp expect actual
9899
'
99100

100101
test_expect_success '--depth limits depth' '
101-
pack=$(git pack-objects --all --depth=5 </dev/null pack) &&
102+
# Avoid --path-walk to avoid breaking delta chains across path
103+
# boundaries.
104+
pack=$(git pack-objects --all --depth=5 --no-path-walk </dev/null pack) &&
102105
echo 5 >expect &&
103106
max_chain pack-$pack.pack >actual &&
104107
test_cmp expect actual

t/t5332-multi-pack-reuse.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ TEST_PASSES_SANITIZE_LEAK=true
88

99
GIT_TEST_MULTI_PACK_INDEX=0
1010
GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=0
11+
12+
# The --path-walk option does not consider the preferred pack
13+
# at all for reusing deltas, so this variable changes the
14+
# behavior of this test, if enabled.
15+
GIT_TEST_PACK_PATH_WALK=0
16+
export GIT_TEST_PACK_PATH_WALK
17+
1118
objdir=.git/objects
1219
packdir=$objdir/pack
1320

t/t5530-upload-pack-error.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ test_expect_success 'upload-pack fails due to error in pack-objects packing' '
3535
hexsz=$(test_oid hexsz) &&
3636
printf "%04xwant %s\n00000009done\n0000" \
3737
$(($hexsz + 10)) $head >input &&
38+
39+
# The current implementation of path-walk causes a different
40+
# error message. This will be changed by a future refactoring.
41+
GIT_TEST_PACK_PATH_WALK=0 &&
42+
export GIT_TEST_PACK_PATH_WALK &&
43+
3844
test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
3945
test_grep "unable to read" output.err &&
4046
test_grep "pack-objects died" output.err

t/t7406-submodule-update.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,12 +1094,16 @@ test_expect_success 'submodule update --quiet passes quietness to fetch with a s
10941094
) &&
10951095
git clone super4 super5 &&
10961096
(cd super5 &&
1097+
# This test variable will create a "warning" message to stderr
1098+
GIT_TEST_PACK_PATH_WALK=0 \
10971099
git submodule update --quiet --init --depth=1 submodule3 >out 2>err &&
10981100
test_must_be_empty out &&
10991101
test_must_be_empty err
11001102
) &&
11011103
git clone super4 super6 &&
11021104
(cd super6 &&
1105+
# This test variable will create a "warning" message to stderr
1106+
GIT_TEST_PACK_PATH_WALK=0 \
11031107
git submodule update --init --depth=1 submodule3 >out 2>err &&
11041108
test_file_not_empty out &&
11051109
test_file_not_empty err

0 commit comments

Comments
 (0)