Merge branch 'ps/maintenance-detach-fix-more' into next
[alt-git.git] / t / t9804-git-p4-label.sh
blobc8963fd3980e0eedff9530d0e9a9d32862b9b05e
1 #!/bin/sh
3 test_description='git p4 label tests'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d' '
9 start_p4d
12 # Basic p4 label tests.
14 # Note: can't have more than one label per commit - others
15 # are silently discarded.
17 test_expect_success 'basic p4 labels' '
18 test_when_finished cleanup_git &&
20 cd "$cli" &&
21 mkdir -p main &&
23 echo f1 >main/f1 &&
24 p4 add main/f1 &&
25 p4 submit -d "main/f1" &&
27 echo f2 >main/f2 &&
28 p4 add main/f2 &&
29 p4 submit -d "main/f2" &&
31 echo f3 >main/file_with_\$metachar &&
32 p4 add main/file_with_\$metachar &&
33 p4 submit -d "file with metachar" &&
35 p4 tag -l tag_f1_only main/f1 &&
36 p4 tag -l tag_with\$_shell_char main/... &&
38 echo f4 >main/f4 &&
39 p4 add main/f4 &&
40 p4 submit -d "main/f4" &&
42 p4 label -i <<-EOF &&
43 Label: long_label
44 Description:
45 A Label first line
46 A Label second line
47 View: //depot/...
48 EOF
50 p4 tag -l long_label ... &&
52 p4 labels ... &&
54 git p4 clone --dest="$git" --detect-labels //depot@all &&
55 cd "$git" &&
57 git tag &&
58 git tag >taglist &&
59 test_line_count = 3 taglist &&
61 cd main &&
62 git checkout tag_tag_f1_only &&
63 ! test -f f2 &&
64 git checkout tag_tag_with\$_shell_char &&
65 test -f f1 && test -f f2 && test -f file_with_\$metachar &&
67 git show tag_long_label | grep -q "A Label second line"
71 # Test some label corner cases:
73 # - two tags on the same file; both should be available
74 # - a tag that is only on one file; this kind of tag
75 # cannot be imported (at least not easily).
77 test_expect_failure 'two labels on the same changelist' '
78 test_when_finished cleanup_git &&
80 cd "$cli" &&
81 mkdir -p main &&
83 p4 edit main/f1 main/f2 &&
84 echo "hello world" >main/f1 &&
85 echo "not in the tag" >main/f2 &&
86 p4 submit -d "main/f[12]: testing two labels" &&
88 p4 tag -l tag_f1_1 main/... &&
89 p4 tag -l tag_f1_2 main/... &&
91 p4 labels ... &&
93 git p4 clone --dest="$git" --detect-labels //depot@all &&
94 cd "$git" &&
96 git tag | grep tag_f1 &&
97 git tag | grep -q tag_f1_1 &&
98 git tag | grep -q tag_f1_2 &&
100 cd main &&
102 git checkout tag_tag_f1_1 &&
103 ls &&
104 test -f f1 &&
106 git checkout tag_tag_f1_2 &&
107 ls &&
108 test -f f1
112 test_done