Skip to content

Commit 090ce15

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 <stolee@gmail.com>
1 parent c896542 commit 090ce15

10 files changed

+60
-7
lines changed

Diff for: builtin/pack-objects.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int delta_search_threads;
220220
static int pack_to_stdout;
221221
static int sparse;
222222
static int thin;
223-
static int path_walk;
223+
static int path_walk = -1;
224224
static int num_preferred_base;
225225
static struct progress *progress_state;
226226

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

41774177
/* Skip objects that do not exist locally. */
4178-
if (exclude_promisor_objects &&
4178+
if ((exclude_promisor_objects || arg_missing_action != MA_ERROR) &&
41794179
oid_object_info_extended(the_repository, oid, &oi,
41804180
OBJECT_INFO_FOR_PREFETCH) < 0)
41814181
continue;
@@ -4593,6 +4593,14 @@ int cmd_pack_objects(int argc,
45934593
if (pack_to_stdout != !base_name || argc)
45944594
usage_with_options(pack_usage, pack_objects_options);
45954595

4596+
if (path_walk < 0) {
4597+
if (use_bitmap_index > 0 ||
4598+
!use_internal_rev_list)
4599+
path_walk = 0;
4600+
else
4601+
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
4602+
}
4603+
45964604
if (depth < 0)
45974605
depth = 0;
45984606
if (depth >= (1 << OE_DEPTH_BITS)) {

Diff for: ci/run-build-and-tests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ linux-TEST-vars)
3232
export GIT_TEST_CHECKOUT_WORKERS=2
3333
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
3434
export GIT_TEST_FULL_NAME_HASH=1
35+
export GIT_TEST_PACK_PATH_WALK=1
3536
;;
3637
linux-clang)
3738
export GIT_TEST_DEFAULT_HASH=sha1

Diff for: t/README

+4
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@ GIT_TEST_PACK_SPARSE=<boolean> if disabled will default the pack-objects
415415
builtin to use the non-sparse object walk. This can still be overridden by
416416
the --sparse command-line argument.
417417

418+
GIT_TEST_PACK_PATH_WALK=<boolean> if enabled will default the pack-objects
419+
builtin to use the path-walk API for the object walk. This can still be
420+
overridden by the --no-path-walk command-line argument.
421+
418422
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
419423
by overriding the minimum number of cache entries required per thread.
420424

Diff for: t/t0411-clone-from-partial.sh

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ test_expect_success 'pack-objects should fetch from promisor remote and execute
5959

6060
test_expect_success 'clone from promisor remote does not lazy-fetch by default' '
6161
rm -f script-executed &&
62+
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+
6268
test_must_fail git clone evil no-lazy 2>err &&
6369
test_grep "lazy fetching disabled" err &&
6470
test_path_is_missing script-executed

Diff for: t/t5306-pack-nobase.sh

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

Diff for: t/t5310-pack-bitmaps.sh

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

Diff for: t/t5316-pack-delta-depth.sh

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

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

Diff for: t/t5332-multi-pack-reuse.sh

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ test_description='pack-objects multi-pack reuse'
77

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

Diff for: t/t5530-upload-pack-error.sh

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

Diff for: t/t7406-submodule-update.sh

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

0 commit comments

Comments
 (0)