3 test_description
='Clone repositories and keep empty commits'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'start p4d' '
12 test_expect_success
'Create a repo' '
13 client_view "//depot/... //client/..." &&
20 p4 add subdir/file1.txt &&
21 p4 submit -d "Add file 1" &&
25 p4 submit -d "Add file 2" &&
28 p4 add subdir/file3.txt &&
29 p4 submit -d "Add file 3" &&
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 &&
49 git p4 clone --use-client-spec --destination="$git" //depot@all &&
50 cat >expect <<-\EOF &&
52 [git-p4: depot-paths = "//depot/": change = 6]
55 [git-p4: depot-paths = "//depot/": change = 5]
58 [git-p4: depot-paths = "//depot/": change = 4]
61 [git-p4: depot-paths = "//depot/": change = 3]
64 [git-p4: depot-paths = "//depot/": change = 2]
67 [git-p4: depot-paths = "//depot/": change = 1]
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 &&
81 git config git-p4.keepEmptyCommits true &&
82 git p4 clone --use-client-spec --destination="$git" //depot@all &&
83 cat >expect <<-\EOF &&
85 [git-p4: depot-paths = "//depot/": change = 6]
88 [git-p4: depot-paths = "//depot/": change = 5]
91 [git-p4: depot-paths = "//depot/": change = 4]
94 [git-p4: depot-paths = "//depot/": change = 3]
97 [git-p4: depot-paths = "//depot/": change = 2]
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 &&
114 git p4 clone --use-client-spec --destination="$git" --verbose //depot@all &&
115 cat >expect <<-\EOF &&
117 [git-p4: depot-paths = "//depot/": change = 5]
120 [git-p4: depot-paths = "//depot/": change = 3]
123 [git-p4: depot-paths = "//depot/": change = 1]
126 git log --format=%B >actual &&
127 test_cmp expect actual