3 test_description
='Test "stg sink"'
7 test_expect_success
'Initialize StGit stack' '
10 git commit -m initial &&
27 stg uncommit p22 p4 p3 p2 p1 &&
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' '
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' '
48 test "$(echo $(stg series --applied --noprefix))" = "p4 p3 p2 p1"
51 test_expect_success
'sink current below a target' '
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" &&
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 &&
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"