Skip to content

Commit 1203ee5

Browse files
committed
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 objets than we desired, due to some incorrect behavior of the path-walk API, especially around walking unintersting objects. Now that these things were fixed, we can make this change. Further, we can add a test to show that the Git client is similarly careful about selecting the right objects during 'git push' from a shallow clone. Signed-off-by: Derrick Stolee <[email protected]>
1 parent d13133b commit 1203ee5

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
201201
static timestamp_t unpack_unreachable_expiration;
202202
static int pack_loose_unreachable;
203203
static int cruft;
204+
static int shallow = 0;
204205
static timestamp_t cruft_expiration;
205206
static int local;
206207
static int have_non_local_packs;
@@ -4438,6 +4439,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
44384439
* base objects.
44394440
*/
44404441
info.prune_all_uninteresting = sparse;
4442+
info.edge_aggressive = shallow;
44414443

44424444
if (walk_objects_by_path(&info))
44434445
die(_("failed to pack objects via path-walk"));
@@ -4627,7 +4629,6 @@ int cmd_pack_objects(int argc,
46274629
struct repository *repo UNUSED)
46284630
{
46294631
int use_internal_rev_list = 0;
4630-
int shallow = 0;
46314632
int all_progress_implied = 0;
46324633
struct strvec rp = STRVEC_INIT;
46334634
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -4812,10 +4813,6 @@ int cmd_pack_objects(int argc,
48124813
warning(_("cannot use delta islands with --path-walk"));
48134814
path_walk = 0;
48144815
}
4815-
if (path_walk && shallow) {
4816-
warning(_("cannot use --shallow with --path-walk"));
4817-
path_walk = 0;
4818-
}
48194816
if (path_walk) {
48204817
strvec_push(&rp, "--boundary");
48214818
/*

t/t5538-push-shallow.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,21 @@ EOF
124124
git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
125125
)
126126
'
127+
128+
test_expect_success 'push new commit from shallow clone to origin is efficient' '
129+
git init origin &&
130+
echo a >origin/a &&
131+
git -C origin add a &&
132+
git -C origin commit -m "base" &&
133+
echo b >origin/b &&
134+
git -C origin add b &&
135+
git -C origin commit -m "tip" &&
136+
137+
git clone --depth=1 "file://$(pwd)/origin" client &&
138+
git -C client checkout -b topic &&
139+
git -C client commit --allow-empty -m "empty" &&
140+
GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err &&
141+
test_grep "Enumerating objects: 1, done." err
142+
'
143+
127144
test_done

0 commit comments

Comments
 (0)