Commit | Line | Data |
---|---|---|
8c8be628 YD |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Yann Dirson | |
4 | # | |
5 | ||
6 | test_description='Exercise pushing patches applied upstream. | |
7 | ||
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.' | |
12 | ||
13 | . ./test-lib.sh | |
14 | ||
15 | # don't need this repo, but better not drop it, see t1100 | |
16 | #rm -rf .git | |
17 | ||
18 | # Need a repo to clone | |
19 | test_create_repo foo | |
20 | ||
21 | test_expect_success \ | |
d67cfe11 KH |
22 | 'Clone tree and setup changes' ' |
23 | stg clone foo bar && | |
24 | ( | |
25 | cd bar && stg new p1 -m p1 && | |
c7506039 | 26 | printf "a\nc\n" > file && stg add file && stg refresh && |
d67cfe11 KH |
27 | stg new p2 -m p2 && |
28 | printf "a\nb\nc\n" > file && stg refresh && | |
f9d9a062 CM |
29 | [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] && |
30 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
d67cfe11 KH |
31 | ) |
32 | ' | |
8c8be628 YD |
33 | |
34 | test_expect_success \ | |
d67cfe11 KH |
35 | 'Port those patches to orig tree' ' |
36 | ( | |
37 | cd foo && | |
04b44217 | 38 | GIT_DIR=../bar/.git git format-patch --stdout \ |
850c3a89 | 39 | $(cd ../bar && stg id master:{base})..HEAD | git am -3 -k |
d67cfe11 KH |
40 | ) |
41 | ' | |
8c8be628 YD |
42 | |
43 | test_expect_success \ | |
44 | 'Pull to sync with parent, preparing for the problem' \ | |
45 | "(cd bar && stg pop --all && | |
46 | stg pull | |
47 | ) | |
48 | " | |
49 | ||
5f594e90 | 50 | test_expect_success \ |
8c8be628 | 51 | 'Attempt to push the first of those patches without --merged' \ |
f979802d | 52 | "(cd bar && conflict stg push |
8c8be628 YD |
53 | ) |
54 | " | |
55 | ||
56 | test_expect_success \ | |
d67cfe11 KH |
57 | 'Rollback the push' ' |
58 | ( | |
625e8de7 | 59 | cd bar && stg undo --hard && |
f9d9a062 CM |
60 | [ "$(echo $(stg series --applied --noprefix))" = "" ] && |
61 | [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ] | |
d67cfe11 KH |
62 | ) |
63 | ' | |
8c8be628 YD |
64 | |
65 | test_expect_success \ | |
d67cfe11 KH |
66 | 'Push those patches while checking they were merged upstream' ' |
67 | ( | |
68 | cd bar && stg push --merged --all | |
f9d9a062 CM |
69 | [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] && |
70 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
d67cfe11 KH |
71 | ) |
72 | ' | |
8c8be628 YD |
73 | |
74 | test_done |