Skip to content

Commit 9d4010e

Browse files
committed
pack-objects: allow --path-walk with --shallow
The --path-walk option is important to reduce the size of pushes from certain pipelines, but many of those pipelines use shallow clones. This results in the 'git push' process passing the '--shallow' option to the underlying 'git pack-objects' process. The previous implementation would disable the --path-walk option in this case, making the feature ineffective. The only change that the --shallow option provides is that the revision walk gains the --objects-edge-aggressive option. This is not necessary for satisfying the requirements of 'git pack-objects', but helps when performing shallow fetches. We already recommend that servers do not use pack.usePathWalk=true, so there is little risk in enabling this option for clients at this time. We may consider expanding the implementation in the future to have this aggressive edge walk, but it doesn't work with the current way that the commit walk is used in the path-walk API. The only necessary change to the test suite (when running with GIT_TEST_PACK_PATH_WALK=1) is to change the number of objects fetched in an example where a new shallow commit is created and a --depth=1 fetch is run. In this case, three objects are fetched instead of one. This is due to the lack of the aggressive edge walk, but would not affect client-side pushes. Signed-off-by: Derrick Stolee <[email protected]>
1 parent dda73ee commit 9d4010e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

builtin/pack-objects.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4812,10 +4812,6 @@ int cmd_pack_objects(int argc,
48124812
warning(_("cannot use delta islands with --path-walk"));
48134813
path_walk = 0;
48144814
}
4815-
if (path_walk && shallow) {
4816-
warning(_("cannot use --shallow with --path-walk"));
4817-
path_walk = 0;
4818-
}
48194815
if (path_walk) {
48204816
strvec_push(&rp, "--boundary");
48214817
/*

t/t5500-fetch-pack.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,18 @@ test_expect_success 'fetch in shallow repo unreachable shallow objects' '
463463
git fsck --no-dangling
464464
)
465465
'
466+
467+
# At the moment, the --path-walk option may provide more objects
468+
# when combined with --shallow than the --no-path-walk option.
469+
if test_bool_env GIT_TEST_PACK_PATH_WALK true
470+
then
471+
EXPECTED_SHALLOW_OBJECTS=3 &&
472+
export EXPECTED_SHALLOW_OBJECTS
473+
else
474+
EXPECTED_SHALLOW_OBJECTS=1 &&
475+
export EXPECTED_SHALLOW_OBJECTS
476+
fi
477+
466478
test_expect_success 'fetch creating new shallow root' '
467479
(
468480
git clone "file://$(pwd)/." shallow10 &&
@@ -471,7 +483,7 @@ test_expect_success 'fetch creating new shallow root' '
471483
git fetch --depth=1 --progress 2>actual &&
472484
# This should fetch only the empty commit, no tree or
473485
# blob objects
474-
test_grep "remote: Total 1" actual
486+
test_grep "remote: Total $EXPECTED_SHALLOW_OBJECTS" actual
475487
)
476488
'
477489

0 commit comments

Comments
 (0)