]>
Commit | Line | Data |
---|---|---|
4820a33b NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='fetch/clone from a shallow clone' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | commit() { | |
8 | echo "$1" >tracked && | |
9 | git add tracked && | |
10 | git commit -m "$1" | |
11 | } | |
12 | ||
13 | test_expect_success 'setup' ' | |
14 | commit 1 && | |
15 | commit 2 && | |
16 | commit 3 && | |
17 | commit 4 && | |
18 | git config --global transfer.fsckObjects true | |
19 | ' | |
20 | ||
21 | test_expect_success 'setup shallow clone' ' | |
22 | git clone --no-local --depth=2 .git shallow && | |
23 | git --git-dir=shallow/.git log --format=%s >actual && | |
24 | cat <<EOF >expect && | |
25 | 4 | |
26 | 3 | |
27 | EOF | |
28 | test_cmp expect actual | |
29 | ' | |
30 | ||
31 | test_expect_success 'clone from shallow clone' ' | |
32 | git clone --no-local shallow shallow2 && | |
33 | ( | |
34 | cd shallow2 && | |
35 | git fsck && | |
36 | git log --format=%s >actual && | |
37 | cat <<EOF >expect && | |
38 | 4 | |
39 | 3 | |
40 | EOF | |
41 | test_cmp expect actual | |
42 | ) | |
43 | ' | |
44 | ||
45 | test_expect_success 'fetch from shallow clone' ' | |
46 | ( | |
47 | cd shallow && | |
48 | commit 5 | |
49 | ) && | |
50 | ( | |
51 | cd shallow2 && | |
52 | git fetch && | |
53 | git fsck && | |
54 | git log --format=%s origin/master >actual && | |
55 | cat <<EOF >expect && | |
56 | 5 | |
57 | 4 | |
58 | 3 | |
59 | EOF | |
60 | test_cmp expect actual | |
61 | ) | |
62 | ' | |
63 | ||
64 | test_expect_success 'fetch --depth from shallow clone' ' | |
65 | ( | |
66 | cd shallow && | |
67 | commit 6 | |
68 | ) && | |
69 | ( | |
70 | cd shallow2 && | |
71 | git fetch --depth=2 && | |
72 | git fsck && | |
73 | git log --format=%s origin/master >actual && | |
74 | cat <<EOF >expect && | |
75 | 6 | |
76 | 5 | |
77 | EOF | |
78 | test_cmp expect actual | |
79 | ) | |
80 | ' | |
81 | ||
82 | test_expect_success 'fetch something upstream has but hidden by clients shallow boundaries' ' | |
83 | # the blob "1" is available in .git but hidden by the | |
84 | # shallow2/.git/shallow and it should be resent | |
85 | ! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object --stdin` >/dev/null && | |
86 | echo 1 >1.t && | |
87 | git add 1.t && | |
88 | git commit -m add-1-back && | |
89 | ( | |
90 | cd shallow2 && | |
91 | git fetch ../.git +refs/heads/master:refs/remotes/top/master && | |
92 | git fsck && | |
93 | git log --format=%s top/master >actual && | |
94 | cat <<EOF >expect && | |
95 | add-1-back | |
96 | 4 | |
97 | 3 | |
98 | EOF | |
99 | test_cmp expect actual | |
100 | ) && | |
101 | git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object --stdin` >/dev/null | |
102 | ||
103 | ' | |
104 | ||
105 | test_expect_success 'fetch that requires changes in .git/shallow is filtered' ' | |
106 | ( | |
107 | cd shallow && | |
108 | git checkout --orphan no-shallow && | |
109 | commit no-shallow | |
110 | ) && | |
111 | git init notshallow && | |
112 | ( | |
113 | cd notshallow && | |
114 | git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&& | |
115 | git for-each-ref --format="%(refname)" >actual.refs && | |
116 | cat <<EOF >expect.refs && | |
117 | refs/remotes/shallow/no-shallow | |
118 | EOF | |
119 | test_cmp expect.refs actual.refs && | |
120 | git log --format=%s shallow/no-shallow >actual && | |
121 | cat <<EOF >expect && | |
122 | no-shallow | |
123 | EOF | |
124 | test_cmp expect actual | |
125 | ) | |
126 | ' | |
127 | ||
128 | test_done |