More robust setup.py code generation
[stgit.git] / t / t1200-push-modified.sh
blobf0bf923d7bf259a39f7298902be5cf31644a5409
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 && stg new p1 -m p1 &&
26 git notes add -m note1 &&
27 printf "a\nc\n" > file && stg add file && stg refresh &&
28 stg new p2 -m p2 &&
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))" = "" ]
36 test_expect_success \
37 'Port those patches to orig tree' '
39 cd foo &&
40 GIT_DIR=../bar/.git git format-patch --stdout \
41 $(cd ../bar && stg id master:{base})..HEAD | git am -3 -k
45 test_expect_success \
46 'Pull to sync with parent, preparing for the problem' \
47 "(cd bar && stg pop --all &&
48 stg pull
52 test_expect_success \
53 'Attempt to push the first of those patches without --merged' \
54 "(cd bar && conflict stg push
58 test_expect_success \
59 'Rollback the push' '
61 cd bar && stg undo --hard &&
62 [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
63 [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
67 test_expect_success \
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" ]
78 test_expect_success \
79 'pop then push a patch with a change to a submodule should not produce a conflict' '
81 cd bar &&
82 stg clone ../foo baz &&
83 stg new p3 -m p3 &&
84 git submodule add ../foo baz &&
85 stg refresh &&
86 (cd baz && git reset --hard HEAD^) &&
87 stg new p4 -m p4 &&
88 stg refresh &&
89 stg pop &&
90 stg push
94 test_done