Normalize formatting of t1200-push-modified.sh.
[stgit.git] / t / t1200-push-modified.sh
blobbc515bf4412b06d01afddd934c3dd36d0293f8f2
1 #!/bin/sh
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.'
13 . ./test-lib.sh
15 # don't need this repo, but better not drop it, see t1100
16 #rm -rf .git
18 # Need a repo to clone
19 test_create_repo foo
21 test_expect_success \
22 'Clone tree and setup changes' '
23 stg clone foo bar &&
25 cd bar &&
26 stg new -m p1 &&
27 git notes add -m note1 &&
28 printf "a\nc\n" > file &&
29 stg add file &&
30 stg refresh &&
31 stg new -m p2 &&
32 git notes add -m note2 &&
33 printf "a\nb\nc\n" > file &&
34 stg refresh &&
35 [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
36 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
40 test_expect_success \
41 'Port those patches to orig tree' '
43 cd foo &&
44 GIT_DIR=../bar/.git git format-patch --stdout \
45 $(cd ../bar && stg id master:{base})..HEAD | git am -3 -k
49 test_expect_success \
50 'Pull to sync with parent, preparing for the problem' '
52 cd bar &&
53 stg pop --all &&
54 stg pull
58 test_expect_success \
59 'Attempt to push the first of those patches without --merged' '
61 cd bar &&
62 conflict stg push
66 test_expect_success \
67 'Rollback the push' '
69 cd bar &&
70 stg undo --hard &&
71 [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
72 [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
76 test_expect_success \
77 'Push those patches while checking they were merged upstream' '
79 cd bar &&
80 stg push --merged --all &&
81 [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
82 [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
83 [ "$(git notes show $(stg id p1))" = "note1" ] &&
84 [ "$(git notes show)" = "note2" ]
88 test_expect_success \
89 'pop then push a patch with a change to a submodule should not produce a conflict' '
91 cd bar &&
92 stg clone ../foo baz &&
93 stg new p3 -m p3 &&
94 git submodule add ../foo baz &&
95 stg refresh &&
96 (cd baz && git reset --hard HEAD^) &&
97 stg new p4 -m p4 &&
98 stg refresh &&
99 stg pop &&
100 stg push
104 test_done