]>
Commit | Line | Data |
---|---|---|
35a7ae95 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='git partial clone' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # create a normal "src" repo where we can later create new commits. | |
8 | # expect_1.oids will contain a list of the OIDs of all blobs. | |
9 | test_expect_success 'setup normal src repo' ' | |
10 | echo "{print \$1}" >print_1.awk && | |
11 | echo "{print \$2}" >print_2.awk && | |
12 | ||
13 | git init src && | |
14 | for n in 1 2 3 4 | |
15 | do | |
16 | echo "This is file: $n" > src/file.$n.txt | |
17 | git -C src add file.$n.txt | |
18 | git -C src commit -m "file $n" | |
19 | git -C src ls-files -s file.$n.txt >>temp | |
20 | done && | |
21 | awk -f print_2.awk <temp | sort >expect_1.oids && | |
22 | test_line_count = 4 expect_1.oids | |
23 | ' | |
24 | ||
25 | # bare clone "src" giving "srv.bare" for use as our server. | |
26 | test_expect_success 'setup bare clone for server' ' | |
27 | git clone --bare "file://$(pwd)/src" srv.bare && | |
28 | git -C srv.bare config --local uploadpack.allowfilter 1 && | |
29 | git -C srv.bare config --local uploadpack.allowanysha1inwant 1 | |
30 | ' | |
31 | ||
32 | # do basic partial clone from "srv.bare" | |
33 | # confirm we are missing all of the known blobs. | |
34 | # confirm partial clone was registered in the local config. | |
35 | test_expect_success 'do partial clone 1' ' | |
36 | git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 && | |
37 | git -C pc1 rev-list HEAD --quiet --objects --missing=print \ | |
38 | | awk -f print_1.awk \ | |
39 | | sed "s/?//" \ | |
40 | | sort >observed.oids && | |
41 | test_cmp expect_1.oids observed.oids && | |
42 | test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" && | |
43 | test "$(git -C pc1 config --local extensions.partialclone)" = "origin" && | |
44 | test "$(git -C pc1 config --local core.partialclonefilter)" = "blob:none" | |
45 | ' | |
46 | ||
47 | # checkout master to force dynamic object fetch of blobs at HEAD. | |
48 | test_expect_success 'verify checkout with dynamic object fetch' ' | |
49 | git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed && | |
50 | test_line_count = 4 observed && | |
51 | git -C pc1 checkout master && | |
52 | git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed && | |
53 | test_line_count = 0 observed | |
54 | ' | |
55 | ||
56 | # create new commits in "src" repo to establish a blame history on file.1.txt | |
57 | # and push to "srv.bare". | |
58 | test_expect_success 'push new commits to server' ' | |
59 | git -C src remote add srv "file://$(pwd)/srv.bare" && | |
60 | for x in a b c d e | |
61 | do | |
62 | echo "Mod $x" >>src/file.1.txt | |
63 | git -C src add file.1.txt | |
64 | git -C src commit -m "mod $x" | |
65 | done && | |
66 | git -C src blame master -- file.1.txt >expect.blame && | |
67 | git -C src push -u srv master | |
68 | ' | |
69 | ||
70 | # (partial) fetch in the partial clone repo from the promisor remote. | |
71 | # verify that fetch inherited the filter-spec from the config and DOES NOT | |
72 | # have the new blobs. | |
73 | test_expect_success 'partial fetch inherits filter settings' ' | |
74 | git -C pc1 fetch origin && | |
75 | git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && | |
76 | test_line_count = 5 observed | |
77 | ' | |
78 | ||
79 | # force dynamic object fetch using diff. | |
80 | # we should only get 1 new blob (for the file in origin/master). | |
81 | test_expect_success 'verify diff causes dynamic object fetch' ' | |
82 | git -C pc1 diff master..origin/master -- file.1.txt && | |
83 | git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && | |
84 | test_line_count = 4 observed | |
85 | ' | |
86 | ||
87 | # force full dynamic object fetch of the file's history using blame. | |
88 | # we should get the intermediate blobs for the file. | |
89 | test_expect_success 'verify blame causes dynamic object fetch' ' | |
90 | git -C pc1 blame origin/master -- file.1.txt >observed.blame && | |
91 | test_cmp expect.blame observed.blame && | |
92 | git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && | |
93 | test_line_count = 0 observed | |
94 | ' | |
95 | ||
96 | test_done |