5c367141ce5083b3ed7d1ff8304d3d85ef44cafa
1#!/bin/sh
2
3test_description='git p4 submit failure handling'
4
5. ./lib-git-p4.sh
6
7test_expect_success 'start p4d' '
8 start_p4d
9'
10
11test_expect_success 'init depot' '
12 (
13 cd "$cli" &&
14 p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&
15 echo line1 >file1 &&
16 p4 add file1 &&
17 p4 submit -d "line1 in file1"
18 )
19'
20
21test_expect_success 'conflict on one commit, skip' '
22 test_when_finished cleanup_git &&
23 git p4 clone --dest="$git" //depot &&
24 (
25 cd "$cli" &&
26 p4 open file1 &&
27 echo line2 >>file1 &&
28 p4 submit -d "line2 in file1"
29 ) &&
30 (
31 # now this commit should cause a conflict
32 cd "$git" &&
33 git config git-p4.skipSubmitEdit true &&
34 echo line3 >>file1 &&
35 git add file1 &&
36 git commit -m "line3 in file1 will conflict" &&
37 echo s | test_expect_code 1 git p4 submit >out &&
38 test_i18ngrep "No commits applied" out
39 )
40'
41
42test_expect_success 'conflict on second of two commits, skip' '
43 test_when_finished cleanup_git &&
44 git p4 clone --dest="$git" //depot &&
45 (
46 cd "$cli" &&
47 p4 open file1 &&
48 echo line3 >>file1 &&
49 p4 submit -d "line3 in file1"
50 ) &&
51 (
52 cd "$git" &&
53 git config git-p4.skipSubmitEdit true &&
54 # this commit is okay
55 test_commit "first_commit_okay" &&
56 # now this submit should cause a conflict
57 echo line4 >>file1 &&
58 git add file1 &&
59 git commit -m "line4 in file1 will conflict" &&
60 echo s | test_expect_code 1 git p4 submit >out &&
61 test_i18ngrep "Applied only the commits" out
62 )
63'
64
65test_expect_success 'conflict on first of two commits, skip' '
66 test_when_finished cleanup_git &&
67 git p4 clone --dest="$git" //depot &&
68 (
69 cd "$cli" &&
70 p4 open file1 &&
71 echo line4 >>file1 &&
72 p4 submit -d "line4 in file1"
73 ) &&
74 (
75 cd "$git" &&
76 git config git-p4.skipSubmitEdit true &&
77 # this submit should cause a conflict
78 echo line5 >>file1 &&
79 git add file1 &&
80 git commit -m "line5 in file1 will conflict" &&
81 # but this commit is okay
82 test_commit "okay_commit_after_skip" &&
83 echo s | test_expect_code 1 git p4 submit >out &&
84 test_i18ngrep "Applied only the commits" out
85 )
86'
87
88test_expect_success 'kill p4d' '
89 kill_p4d
90'
91
92test_done