Tests redirect to err file when grepping stderr
[stgit.git] / t / t1501-sink.sh
blob901ea71056c5e1df77893d51fcbd6f96ae4da523
1 #!/bin/sh
3 test_description='Test "stg sink"'
5 . ./test-lib.sh
7 test_expect_success 'Initialize StGit stack' '
8 echo 0 >> f0 &&
9 stg add f0 &&
10 git commit -m initial &&
11 echo 1 >> f1 &&
12 stg add f1 &&
13 git commit -m p1 &&
14 echo 2 >> f2 &&
15 stg add f2 &&
16 git commit -m p2 &&
17 echo 3 >> f3 &&
18 stg add f3 &&
19 git commit -m p3 &&
20 echo 4 >> f4 &&
21 stg add f4 &&
22 git commit -m p4 &&
23 echo 22 >> f2 &&
24 stg add f2 &&
25 git commit -m p22 &&
26 stg init &&
27 stg uncommit p22 p4 p3 p2 p1 &&
28 stg pop -a
31 test_expect_success 'sink default without applied patches' '
32 command_error stg sink 2>err &&
33 grep -e "No patches to sink" err
36 test_expect_success 'sink and reorder specified without applied patches' '
37 stg sink p2 p1 &&
38 test "$(echo $(stg series --applied --noprefix))" = "p2 p1"
41 test_expect_success 'attempt sink below unapplied' '
42 command_error stg sink --to=p4 2>err &&
43 grep -e "Cannot sink below p4 since it is not applied" err
46 test_expect_success 'sink patches to the bottom of the stack' '
47 stg sink p4 p3 p2 &&
48 test "$(echo $(stg series --applied --noprefix))" = "p4 p3 p2 p1"
51 test_expect_success 'sink current below a target' '
52 stg sink --to=p2 &&
53 test "$(echo $(stg series --applied --noprefix))" = "p4 p3 p1 p2"
56 test_expect_success 'bring patches forward' '
57 stg sink --to=p2 p3 p4 &&
58 test "$(echo $(stg series --applied --noprefix))" = "p1 p3 p4 p2"
61 test_expect_success 'sink specified patch below a target' '
62 stg sink --to=p3 p2 &&
63 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4"
66 test_expect_success 'sink --nopush' '
67 stg sink --nopush --to=p2 &&
68 test "$(echo $(stg series --applied --noprefix))" = "p1 p4" &&
69 test "$(echo $(stg series --unapplied --noprefix))" = "p2 p3 p22"
72 test_expect_success 'sink --nopush with multiple patches' '
73 stg sink --nopush p1 p2 p3 &&
74 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
75 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p22" &&
76 stg goto p4
79 test_expect_success 'attempt sink with same to and target' '
80 command_error stg sink --to=p3 p3 2>err &&
81 grep -e "Cannot have a sinked patch as target" err &&
82 rm err
85 test_expect_success 'sink with conflict' '
86 conflict stg sink --to=p2 p22 &&
87 test "$(echo $(stg series --applied --noprefix))" = "p1 p22" &&
88 test "$(echo $(stg status))" = "DU f2"
91 test_done