1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#!/bin/sh
#
# Copyright (c) 2006 Yann Dirson
#
test_description='Exercise pushing patches applied upstream.
Especially, consider the case of a patch that adds a file, while a
subsequent one modifies it, so we have to use --merged for push to
detect the merge. Reproduce the common workflow where one does not
specify --merged, then rollback and retry with the correct flag.'
. ./test-lib.sh
# don't need this repo, but better not drop it, see t1100
#rm -rf .git
# Need a repo to clone
test_create_repo foo
test_expect_success \
'Clone tree and setup changes' '
stg clone foo bar &&
(
cd bar && stg new p1 -m p1 &&
printf "a\nc\n" > file && stg add file && stg refresh &&
stg new p2 -m p2 &&
printf "a\nb\nc\n" > file && stg refresh &&
[ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
)
'
test_expect_success \
'Port those patches to orig tree' '
(
cd foo &&
GIT_DIR=../bar/.git git format-patch --stdout \
$(cd ../bar && stg id master:{base})..HEAD | git am -3 -k
)
'
test_expect_success \
'Pull to sync with parent, preparing for the problem' \
"(cd bar && stg pop --all &&
stg pull
)
"
test_expect_success \
'Attempt to push the first of those patches without --merged' \
"(cd bar && conflict stg push
)
"
test_expect_success \
'Rollback the push' '
(
cd bar && stg undo --hard &&
[ "$(echo $(stg series --applied --noprefix))" = "" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
)
'
test_expect_success \
'Push those patches while checking they were merged upstream' '
(
cd bar && stg push --merged --all
[ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
)
'
test_expect_success \
'pop then push a patch with a change to a submodule should not produce a conflict' '
(
cd bar &&
stg clone ../foo baz &&
stg new p3 -m p3 &&
git submodule add ../foo baz &&
stg refresh &&
(cd baz && git reset --hard HEAD^) &&
stg new p4 -m p4 &&
stg refresh &&
stg pop &&
stg push
)
'
test_done
|