1#!/bin/sh
2#
3# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
4#
5
6test_description='git cherry should detect patches integrated upstream
7
8This test cherry-picks one local change of two into master branch, and
9checks that git cherry only returns the second patch in the local branch
10'
11. ./test-lib.sh
12
13export GIT_AUTHOR_EMAIL=bogus_email_address
14
15test_expect_success \
16 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
17 'echo First > A &&
18 git update-index --add A &&
19 git-commit -m "Add A." &&
20
21 git-checkout -b my-topic-branch &&
22
23 echo Second > B &&
24 git update-index --add B &&
25 git-commit -m "Add B." &&
26
27 sleep 2 &&
28 echo AnotherSecond > C &&
29 git update-index --add C &&
30 git-commit -m "Add C." &&
31
32 git-checkout -f master &&
33 rm -f B C &&
34
35 echo Third >> A &&
36 git update-index A &&
37 git-commit -m "Modify A." &&
38
39 expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*"
40'
41
42test_expect_success \
43 'check that cherry with limit returns only the top patch'\
44 'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
45'
46
47test_expect_success \
48 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \
49 'git cherry-pick my-topic-branch^0 &&
50 echo $(git cherry master my-topic-branch) &&
51 expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
52'
53
54test_done