]>
Commit | Line | Data |
---|---|---|
b91db270 YD |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git cherry should detect patches integrated upstream |
b91db270 YD |
7 | |
8 | This test cherry-picks one local change of two into master branch, and | |
5be60078 | 9 | checks that git cherry only returns the second patch in the local branch |
b91db270 | 10 | ' |
334afbc7 JS |
11 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master |
12 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
13 | ||
b91db270 YD |
14 | . ./test-lib.sh |
15 | ||
0e46e704 BD |
16 | GIT_AUTHOR_EMAIL=bogus_email_address |
17 | export GIT_AUTHOR_EMAIL | |
b91db270 YD |
18 | |
19 | test_expect_success \ | |
20 | 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \ | |
21 | 'echo First > A && | |
5be60078 | 22 | git update-index --add A && |
016e5ff2 | 23 | test_tick && |
0cb0e143 | 24 | git commit -m "Add A." && |
b91db270 | 25 | |
0cb0e143 | 26 | git checkout -b my-topic-branch && |
b91db270 YD |
27 | |
28 | echo Second > B && | |
5be60078 | 29 | git update-index --add B && |
016e5ff2 | 30 | test_tick && |
0cb0e143 | 31 | git commit -m "Add B." && |
b91db270 | 32 | |
b91db270 | 33 | echo AnotherSecond > C && |
5be60078 | 34 | git update-index --add C && |
016e5ff2 | 35 | test_tick && |
0cb0e143 | 36 | git commit -m "Add C." && |
b91db270 | 37 | |
0cb0e143 | 38 | git checkout -f master && |
fcc387db | 39 | rm -f B C && |
b91db270 YD |
40 | |
41 | echo Third >> A && | |
5be60078 | 42 | git update-index A && |
016e5ff2 | 43 | test_tick && |
0cb0e143 | 44 | git commit -m "Modify A." && |
b91db270 | 45 | |
5be60078 | 46 | expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*" |
b91db270 YD |
47 | ' |
48 | ||
49 | test_expect_success \ | |
50 | 'check that cherry with limit returns only the top patch'\ | |
5be60078 | 51 | 'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" |
b91db270 YD |
52 | ' |
53 | ||
54 | test_expect_success \ | |
55 | 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ | |
5be60078 JH |
56 | 'git cherry-pick my-topic-branch^0 && |
57 | echo $(git cherry master my-topic-branch) && | |
58 | expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*" | |
b91db270 YD |
59 | ' |
60 | ||
82a62015 RS |
61 | test_expect_success 'cherry ignores whitespace' ' |
62 | git switch --orphan=upstream-with-space && | |
63 | test_commit initial file && | |
64 | >expect && | |
65 | git switch --create=feature-without-space && | |
66 | ||
67 | # A spaceless file on the feature branch. Expect a match upstream. | |
68 | printf space >file && | |
69 | git add file && | |
70 | git commit -m"file without space" && | |
71 | git log --format="- %H" -1 >>expect && | |
72 | ||
73 | # A further change. Should not match upstream. | |
74 | test_commit change file && | |
75 | git log --format="+ %H" -1 >>expect && | |
76 | ||
77 | git switch upstream-with-space && | |
78 | # Same as the spaceless file, just with spaces and on upstream. | |
79 | test_commit "file with space" file "s p a c e" file-with-space && | |
80 | git cherry upstream-with-space feature-without-space >actual && | |
81 | test_cmp expect actual | |
82 | ' | |
83 | ||
b91db270 | 84 | test_done |