Skip to content

Commit 2aeeaac

Browse files
derrickstoleedscho
authored andcommitted
pack-objects: allow --shallow and --path-walk
There does not appear to be anything particularly incompatible about the --shallow and --path-walk options of 'git pack-objects'. If shallow commits are to be handled differently, then it is by the revision walk that defines the commit set and which are interesting or uninteresting. However, before the previous change, a trivial removal of the warning would cause a failure in t5500-fetch-pack.sh when GIT_TEST_PACK_PATH_WALK is enabled. The shallow fetch would provide more objects than we desired, due to some incorrect behavior of the path-walk API, especially around walking uninteresting objects. The recently-added tests in t5538-push-shallow.sh help to confirm this behavior is working with the --path-walk option if GIT_TEST_PACK_PATH_WALK is enabled. These tests passed previously due to the --path-walk feature being disabled in the presence of a shallow clone. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6195b53 commit 2aeeaac

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
204204
static timestamp_t unpack_unreachable_expiration;
205205
static int pack_loose_unreachable;
206206
static int cruft;
207+
static int shallow = 0;
207208
static timestamp_t cruft_expiration;
208209
static int local;
209210
static int have_non_local_packs;
@@ -4568,6 +4569,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
45684569
* base objects.
45694570
*/
45704571
info.prune_all_uninteresting = sparse;
4572+
info.edge_aggressive = shallow;
45714573

45724574
trace2_region_enter("pack-objects", "path-walk", revs->repo);
45734575
result = walk_objects_by_path(&info);
@@ -4773,7 +4775,6 @@ int cmd_pack_objects(int argc,
47734775
struct repository *repo UNUSED)
47744776
{
47754777
int use_internal_rev_list = 0;
4776-
int shallow = 0;
47774778
int all_progress_implied = 0;
47784779
struct strvec rp = STRVEC_INIT;
47794780
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -4961,10 +4962,6 @@ int cmd_pack_objects(int argc,
49614962
warning(_("cannot use delta islands with --path-walk"));
49624963
path_walk = 0;
49634964
}
4964-
if (path_walk && shallow) {
4965-
warning(_("cannot use --shallow with --path-walk"));
4966-
path_walk = 0;
4967-
}
49684965
if (path_walk) {
49694966
strvec_push(&rp, "--boundary");
49704967
/*

t/t5538-push-shallow.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,15 @@ test_expect_success 'push new commit from shallow clone has good deltas' '
153153
154154
# If the delta base is found, then this message uses "bytes".
155155
# If the delta base is not found, then this message uses "KiB".
156-
test_grep "Writing objects: .* bytes" err
156+
test_grep "Writing objects: .* bytes" err &&
157+
158+
git -C deltas commit --amend -m "changed message" &&
159+
GIT_TRACE2_EVENT="$(pwd)/config-push.txt" \
160+
GIT_PROGRESS_DELAY=0 git -C deltas -c pack.usePathWalk=true \
161+
push --progress -f origin deltas 2>err &&
162+
163+
test_grep "Enumerating objects: 1, done" err &&
164+
test_region pack-objects path-walk config-push.txt
157165
'
158166

159167
test_done

0 commit comments

Comments
 (0)