2006-01-08 01:38:15 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
|
|
|
|
#
|
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
test_description='git cherry should detect patches integrated upstream
|
2006-01-08 01:38:15 +01:00
|
|
|
|
|
|
|
This test cherry-picks one local change of two into master branch, and
|
2007-07-03 07:52:14 +02:00
|
|
|
checks that git cherry only returns the second patch in the local branch
|
2006-01-08 01:38:15 +01:00
|
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2008-05-04 07:37:58 +02:00
|
|
|
GIT_AUTHOR_EMAIL=bogus_email_address
|
|
|
|
export GIT_AUTHOR_EMAIL
|
2006-01-08 01:38:15 +01:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
|
|
|
|
'echo First > A &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index --add A &&
|
2010-04-07 02:08:54 +02:00
|
|
|
test_tick &&
|
2008-09-03 10:59:27 +02:00
|
|
|
git commit -m "Add A." &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
2008-09-03 10:59:27 +02:00
|
|
|
git checkout -b my-topic-branch &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
|
|
|
echo Second > B &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index --add B &&
|
2010-04-07 02:08:54 +02:00
|
|
|
test_tick &&
|
2008-09-03 10:59:27 +02:00
|
|
|
git commit -m "Add B." &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
|
|
|
echo AnotherSecond > C &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index --add C &&
|
2010-04-07 02:08:54 +02:00
|
|
|
test_tick &&
|
2008-09-03 10:59:27 +02:00
|
|
|
git commit -m "Add C." &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
2008-09-03 10:59:27 +02:00
|
|
|
git checkout -f master &&
|
2006-05-17 10:17:46 +02:00
|
|
|
rm -f B C &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
|
|
|
echo Third >> A &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index A &&
|
2010-04-07 02:08:54 +02:00
|
|
|
test_tick &&
|
2008-09-03 10:59:27 +02:00
|
|
|
git commit -m "Modify A." &&
|
2006-01-08 01:38:15 +01:00
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*"
|
2006-01-08 01:38:15 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'check that cherry with limit returns only the top patch'\
|
2007-07-03 07:52:14 +02:00
|
|
|
'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
|
2006-01-08 01:38:15 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cherry-pick my-topic-branch^0 &&
|
|
|
|
echo $(git cherry master my-topic-branch) &&
|
|
|
|
expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
|
2006-01-08 01:38:15 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|