Merge branch 'jc/ci-upload-artifact-and-linux32'
[git/gitster.git] / t / t9826-git-p4-keep-empty-commits.sh
blob54083f842e9259ca21f0e6e5f1fe8a20bb74092e
1 #!/bin/sh
3 test_description='Clone repositories and keep empty commits'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d' '
9 start_p4d
12 test_expect_success 'Create a repo' '
13 client_view "//depot/... //client/..." &&
15 cd "$cli" &&
17 mkdir -p subdir &&
19 >subdir/file1.txt &&
20 p4 add subdir/file1.txt &&
21 p4 submit -d "Add file 1" &&
23 >file2.txt &&
24 p4 add file2.txt &&
25 p4 submit -d "Add file 2" &&
27 >subdir/file3.txt &&
28 p4 add subdir/file3.txt &&
29 p4 submit -d "Add file 3" &&
31 >file4.txt &&
32 p4 add file4.txt &&
33 p4 submit -d "Add file 4" &&
35 p4 delete subdir/file3.txt &&
36 p4 submit -d "Remove file 3" &&
38 p4 delete file4.txt &&
39 p4 submit -d "Remove file 4"
43 test_expect_success 'Clone repo root path with all history' '
44 client_view "//depot/... //client/..." &&
45 test_when_finished cleanup_git &&
47 cd "$git" &&
48 git init . &&
49 git p4 clone --use-client-spec --destination="$git" //depot@all &&
50 cat >expect <<-\EOF &&
51 Remove file 4
52 [git-p4: depot-paths = "//depot/": change = 6]
54 Remove file 3
55 [git-p4: depot-paths = "//depot/": change = 5]
57 Add file 4
58 [git-p4: depot-paths = "//depot/": change = 4]
60 Add file 3
61 [git-p4: depot-paths = "//depot/": change = 3]
63 Add file 2
64 [git-p4: depot-paths = "//depot/": change = 2]
66 Add file 1
67 [git-p4: depot-paths = "//depot/": change = 1]
69 EOF
70 git log --format=%B >actual &&
71 test_cmp expect actual
75 test_expect_success 'Clone repo subdir with all history but keep empty commits' '
76 client_view "//depot/subdir/... //client/subdir/..." &&
77 test_when_finished cleanup_git &&
79 cd "$git" &&
80 git init . &&
81 git config git-p4.keepEmptyCommits true &&
82 git p4 clone --use-client-spec --destination="$git" //depot@all &&
83 cat >expect <<-\EOF &&
84 Remove file 4
85 [git-p4: depot-paths = "//depot/": change = 6]
87 Remove file 3
88 [git-p4: depot-paths = "//depot/": change = 5]
90 Add file 4
91 [git-p4: depot-paths = "//depot/": change = 4]
93 Add file 3
94 [git-p4: depot-paths = "//depot/": change = 3]
96 Add file 2
97 [git-p4: depot-paths = "//depot/": change = 2]
99 Add file 1
100 [git-p4: depot-paths = "//depot/": change = 1]
103 git log --format=%B >actual &&
104 test_cmp expect actual
108 test_expect_success 'Clone repo subdir with all history' '
109 client_view "//depot/subdir/... //client/subdir/..." &&
110 test_when_finished cleanup_git &&
112 cd "$git" &&
113 git init . &&
114 git p4 clone --use-client-spec --destination="$git" --verbose //depot@all &&
115 cat >expect <<-\EOF &&
116 Remove file 3
117 [git-p4: depot-paths = "//depot/": change = 5]
119 Add file 3
120 [git-p4: depot-paths = "//depot/": change = 3]
122 Add file 1
123 [git-p4: depot-paths = "//depot/": change = 1]
126 git log --format=%B >actual &&
127 test_cmp expect actual
131 test_done