Commit | Line | Data |
---|---|---|
b0dfbed3 | 1 | #!/bin/sh |
051090dd | 2 | test_description='Test git/StGit interoperability with "stg repair"' |
b0dfbed3 KH |
3 | . ./test-lib.sh |
4 | ||
5 | test_expect_success 'Create some git-only history' ' | |
6 | echo foo > foo.txt && | |
7 | git add foo.txt && | |
8 | git commit -a -m foo && | |
9 | git tag foo-tag && | |
10 | for i in 0 1 2 3 4; do | |
11 | echo foo$i >> foo.txt && | |
12 | git commit -a -m foo$i; | |
13 | done | |
14 | ' | |
15 | ||
16 | test_expect_success 'Initialize the StGit repository' ' | |
17 | stg init | |
18 | ' | |
19 | ||
20 | test_expect_success 'Create five patches' ' | |
21 | for i in 0 1 2 3 4; do | |
22 | stg new p$i -m p$i; | |
23 | done && | |
f9d9a062 CM |
24 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4" ] && |
25 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
b0dfbed3 KH |
26 | ' |
27 | ||
04b44217 | 28 | test_expect_success 'Pop two patches with git reset' ' |
b0dfbed3 | 29 | git reset --hard HEAD~2 && |
f03004e2 | 30 | command_error stg refresh && |
051090dd | 31 | stg repair && |
b0dfbed3 | 32 | stg refresh && |
f9d9a062 CM |
33 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] && |
34 | [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ] | |
b0dfbed3 KH |
35 | ' |
36 | ||
37 | test_expect_success 'Create a new patch' ' | |
38 | stg new q0 -m q0 && | |
f9d9a062 CM |
39 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 q0" ] && |
40 | [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ] | |
b0dfbed3 KH |
41 | ' |
42 | ||
04b44217 | 43 | test_expect_success 'Go to an unapplied patch with with git reset' ' |
b0dfbed3 | 44 | git reset --hard $(stg id p3) && |
f03004e2 | 45 | command_error stg refresh && |
051090dd | 46 | stg repair && |
b0dfbed3 | 47 | stg refresh && |
f9d9a062 CM |
48 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] && |
49 | [ "$(echo $(stg series --unapplied --noprefix))" = "q0 p4" ] | |
b0dfbed3 KH |
50 | ' |
51 | ||
04b44217 | 52 | test_expect_success 'Go back to below the stack base with git reset' ' |
b0dfbed3 | 53 | git reset --hard foo-tag && |
051090dd | 54 | stg repair && |
f9d9a062 CM |
55 | [ "$(echo $(stg series --applied --noprefix))" = "" ] && |
56 | [ "$(echo $(stg series --unapplied --noprefix))" = "p0 p1 p2 p3 q0 p4" ] | |
b0dfbed3 KH |
57 | ' |
58 | ||
59 | test_done |