3 # Copyright (c) 2006 Yann Dirson
6 test_description
='Exercise pushing patches applied upstream.
8 Especially, consider the case of a patch that adds a file, while a
9 subsequent one modifies it, so we have to use --merged for push to
10 detect the merge. Reproduce the common workflow where one does not
11 specify --merged, then rollback and retry with the correct flag.'
15 # don't need this repo, but better not drop it, see t1100
18 # Need a repo to clone
22 'Clone tree and setup changes' '
25 cd bar && stg new p1 -m p1 &&
26 git notes add -m note1 &&
27 printf "a\nc\n" > file && stg add file && stg refresh &&
29 git notes add -m note2 &&
30 printf "a\nb\nc\n" > file && stg refresh &&
31 [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
32 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
37 'Port those patches to orig tree' '
40 GIT_DIR=../bar/.git git format-patch --stdout \
41 $(cd ../bar && stg id master:{base})..HEAD | git am -3 -k
46 'Pull to sync with parent, preparing for the problem' \
47 "(cd bar && stg pop --all &&
53 'Attempt to push the first of those patches without --merged' \
54 "(cd bar && conflict stg push
61 cd bar && stg undo --hard &&
62 [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
63 [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
68 'Push those patches while checking they were merged upstream' '
70 cd bar && stg push --merged --all
71 [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
72 [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
73 [ "$(git notes show $(stg id p1))" = "note1" ] &&
74 [ "$(git notes show)" = "note2" ]
79 'pop then push a patch with a change to a submodule should not produce a conflict' '
82 stg clone ../foo baz &&
84 git submodule add ../foo baz &&
86 (cd baz && git reset --hard HEAD^) &&