@matheusbsbs / matheus-bagliano / commits / 1211be6bed
Fork 0

Make thin-pack generation subproject aware.

When a thin pack wants to send a tree object at "sub/dir", and the commit that is common between the sender and the receiver that is used as the base object has a subproject at that path, we should not try to use the data at "sub/dir" of the base tree as a tree object. It is not a tree to begin with, and more importantly, the commit object there does not have to even exist. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Aug 17, 2007 at 09:56 UTC 1211be6bed1146dcef953c7c2ab332ee995f7152
2 files changed +54
builtin-pack-objects.c
+2
@@ -979,6 +979,8 @@ static void add_pbase_object(struct tree_desc *tree,
979 int cmp;
980
981 while (tree_entry(tree,&entry)) {
982 + if (S_ISGITLINK(entry.mode))
983 + continue;
984 cmp = tree_entry_len(entry.path, entry.sha1) != cmplen ? 1 :
985 memcmp(name, entry.path, cmplen);
986 if (cmp > 0)
t/t3050-subprojects-fetch.sh new
+52
@@ -0,0 +1,52 @@
1 +#!/bin/sh
2 +
3 +test_description='fetching and pushing project with subproject'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 + test_tick &&
9 + mkdir -p sub && (
10 + cd sub &&
11 + git init &&
12 + >subfile &&
13 + git add subfile
14 + git commit -m "subproject commit #1"
15 + ) &&
16 + >mainfile
17 + git add sub mainfile &&
18 + test_tick &&
19 + git commit -m "superproject commit #1"
20 +'
21 +
22 +test_expect_success clone '
23 + git clone file://`pwd`/.git cloned &&
24 + (git rev-parse HEAD; git ls-files -s) >expected &&
25 + (
26 + cd cloned &&
27 + (git rev-parse HEAD; git ls-files -s) >../actual
28 + ) &&
29 + diff -u expected actual
30 +'
31 +
32 +test_expect_success advance '
33 + echo more >mainfile &&
34 + git update-index --force-remove sub &&
35 + mv sub/.git sub/.git-disabled &&
36 + git add sub/subfile mainfile &&
37 + mv sub/.git-disabled sub/.git &&
38 + test_tick &&
39 + git commit -m "superproject commit #2"
40 +'
41 +
42 +test_expect_success fetch '
43 + (git rev-parse HEAD; git ls-files -s) >expected &&
44 + (
45 + cd cloned &&
46 + git pull &&
47 + (git rev-parse HEAD; git ls-files -s) >../actual
48 + ) &&
49 + diff -u expected actual
50 +'
51 +
52 +test_done