Skip to content

Commit 305e19b

Browse files
committed
Merge branch 'mh/fetch-into-shallow'
"git fetch" into a shallow repository from a repository that does not know about the shallow boundary commits (e.g. a different fork from the repository the current shallow repository was cloned from) did not work correctly. * mh/fetch-into-shallow: t5500: add test for fetching with an unknown 'shallow' upload-pack: ignore 'shallow' lines with unknown obj-ids
2 parents 1ccb22d + 71d5f93 commit 305e19b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Documentation/technical/pack-protocol.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ obtained through ref discovery.
228228
The client MUST write all obj-ids which it only has shallow copies
229229
of (meaning that it does not have the parents of a commit) as
230230
'shallow' lines so that the server is aware of the limitations of
231-
the client's history. Clients MUST NOT mention an obj-id which
232-
it does not know exists on the server.
231+
the client's history.
233232

234233
The client now sends the maximum commit history depth it wants for
235234
this transaction, which is the number of commits it wants from the

t/t5500-fetch-pack.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,20 @@ test_expect_success 'clone shallow with packed refs' '
373373
test_cmp count8.expected count8.actual
374374
'
375375

376+
test_expect_success 'fetch in shallow repo unreachable shallow objects' '
377+
(
378+
git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog &&
379+
git clone --depth 1 "file://$(pwd)/no-reflog" shallow9 &&
380+
cd no-reflog &&
381+
git tag -d TAGB1 TAGB2 &&
382+
git update-ref refs/heads/B B~~ &&
383+
git gc --prune=now &&
384+
cd ../shallow9 &&
385+
git fetch origin &&
386+
git fsck --no-dangling
387+
)
388+
'
389+
376390
test_expect_success 'setup tests for the --stdin parameter' '
377391
for head in C D E F
378392
do

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ static void receive_needs(void)
592592
die("invalid shallow line: %s", line);
593593
object = parse_object(sha1);
594594
if (!object)
595-
die("did not find object for %s", line);
595+
continue;
596596
if (object->type != OBJ_COMMIT)
597597
die("invalid shallow object %s", sha1_to_hex(sha1));
598598
if (!(object->flags & CLIENT_SHALLOW)) {

0 commit comments

Comments
 (0)