Skip to content

Commit c178b02

Browse files
derrickstoleegitster
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 4705889 commit c178b02

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
210210
static timestamp_t unpack_unreachable_expiration;
211211
static int pack_loose_unreachable;
212212
static int cruft;
213+
static int shallow = 0;
213214
static timestamp_t cruft_expiration;
214215
static int local;
215216
static int have_non_local_packs;
@@ -4490,6 +4491,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
44904491
* base objects.
44914492
*/
44924493
info.prune_all_uninteresting = sparse;
4494+
info.edge_aggressive = shallow;
44934495

44944496
trace2_region_enter("pack-objects", "path-walk", revs->repo);
44954497
result = walk_objects_by_path(&info);
@@ -4695,7 +4697,6 @@ int cmd_pack_objects(int argc,
46954697
struct repository *repo UNUSED)
46964698
{
46974699
int use_internal_rev_list = 0;
4698-
int shallow = 0;
46994700
int all_progress_implied = 0;
47004701
struct strvec rp = STRVEC_INIT;
47014702
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -4881,8 +4882,6 @@ int cmd_pack_objects(int argc,
48814882
option = "--filter";
48824883
else if (use_delta_islands)
48834884
option = "--delta-islands";
4884-
else if (shallow)
4885-
option = "--shallow";
48864885

48874886
if (option) {
48884887
warning(_("cannot use %s with %s"),

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)