1#!/bin/sh23test_description='test cherry-pick and revert with renames45--6+ rename2: renames oops to opos7+ rename1: renames oops to spoo8+ added: adds extra line to oops9++ initial: has lines in oops1011'1213. ./test-lib.sh1415test_expect_success setup '1617for l in a b c d e f g h i j k l m n o18do19echo $l$l$l$l$l$l$l$l$l20done >oops &&2122test_tick &&23git add oops &&24git commit -m initial &&25git tag initial &&2627test_tick &&28echo "Add extra line at the end" >>oops &&29git commit -a -m added &&30git tag added &&3132test_tick &&33git mv oops spoo &&34git commit -m rename1 &&35git tag rename1 &&3637test_tick &&38git checkout -b side initial &&39git mv oops opos &&40git commit -m rename2 &&41git tag rename242'4344test_expect_success 'cherry-pick --nonsense' '4546pos=$(git rev-parse HEAD) &&47git diff --exit-code HEAD &&48test_must_fail git cherry-pick --nonsense 2>msg &&49git diff --exit-code HEAD "$pos" &&50test_i18ngrep '[Uu]sage:' msg51'5253test_expect_success 'revert --nonsense' '5455pos=$(git rev-parse HEAD) &&56git diff --exit-code HEAD &&57test_must_fail git revert --nonsense 2>msg &&58git diff --exit-code HEAD "$pos" &&59test_i18ngrep '[Uu]sage:' msg60'6162test_expect_success 'cherry-pick after renaming branch' '6364git checkout rename2 &&65git cherry-pick added &&66test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&67test -f opos &&68grep "Add extra line at the end" opos &&69git reflog -1 | grep cherry-pick7071'7273test_expect_success 'revert after renaming branch' '7475git checkout rename1 &&76git revert added &&77test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&78test -f spoo &&79! grep "Add extra line at the end" spoo &&80git reflog -1 | grep revert8182'8384test_expect_success 'cherry-pick on stat-dirty working tree' '85git clone . copy &&86(87cd copy &&88git checkout initial &&89test-chmtime +40 oops &&90git cherry-pick added91)92'9394test_expect_success 'revert forbidden on dirty working tree' '9596echo content >extra_file &&97git add extra_file &&98test_must_fail git revert HEAD 2>errors &&99test_i18ngrep "Your local changes would be overwritten by " errors100101'102103test_expect_success 'chery-pick on unborn branch' '104git checkout --orphan unborn &&105git rm --cached -r . &&106rm -rf * &&107git cherry-pick initial &&108git diff --quiet initial &&109! test_cmp_rev initial HEAD110'111112test_done