Skip to content

Commit d8b1ce7

Browse files
committed
Merge branch 'jt/diff-lazy-fetch-submodule-fix'
On-demand object fetching in lazy clone incorrectly tried to fetch commits from submodule projects, while still working in the superproject, which has been corrected. * jt/diff-lazy-fetch-submodule-fix: diff: skip GITLINK when lazy fetching missing objs
2 parents 8ce8a63 + a63694f commit d8b1ce7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6512,6 +6512,7 @@ static void add_if_missing(struct repository *r,
65126512
const struct diff_filespec *filespec)
65136513
{
65146514
if (filespec && filespec->oid_valid &&
6515+
!S_ISGITLINK(filespec->mode) &&
65156516
oid_object_info_extended(r, &filespec->oid, NULL,
65166517
OBJECT_INFO_FOR_PREFETCH))
65176518
oid_array_append(to_fetch, &filespec->oid);

t/t4067-diff-partial-clone.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,37 @@ test_expect_success 'diff skips same-OID blobs' '
7575
! grep "want $(cat hash-b)" trace
7676
'
7777

78+
test_expect_success 'when fetching missing objects, diff skips GITLINKs' '
79+
test_when_finished "rm -rf sub server client trace" &&
80+
81+
test_create_repo sub &&
82+
test_commit -C sub first &&
83+
84+
test_create_repo server &&
85+
echo a >server/a &&
86+
git -C server add a &&
87+
git -C server submodule add "file://$(pwd)/sub" &&
88+
git -C server commit -m x &&
89+
90+
test_commit -C server/sub second &&
91+
echo another-a >server/a &&
92+
git -C server add a sub &&
93+
git -C server commit -m x &&
94+
95+
test_config -C server uploadpack.allowfilter 1 &&
96+
test_config -C server uploadpack.allowanysha1inwant 1 &&
97+
git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
98+
99+
echo a | git hash-object --stdin >hash-old-a &&
100+
echo another-a | git hash-object --stdin >hash-new-a &&
101+
102+
# Ensure that a and another-a are fetched, and check (by successful
103+
# execution of the diff) that no invalid OIDs are sent.
104+
GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
105+
grep "want $(cat hash-old-a)" trace &&
106+
grep "want $(cat hash-new-a)" trace
107+
'
108+
78109
test_expect_success 'diff with rename detection batches blobs' '
79110
test_when_finished "rm -rf server client trace" &&
80111

0 commit comments

Comments
 (0)