3 # Copyright (c) 2006 Ilpo Järvinen
6 test_description
='Test "stg goto"'
10 test_expect_success
'Initialize stgit repository' '
12 for i in 1 2 3 4 5; do
13 stg new p$i -m "patch $i" &&
20 test_expect_success
'Test invalid number of arguments' '
21 command_error stg goto 2>&1 |
22 grep -e "incorrect number of arguments"
25 test_expect_success
'Goto current patch' '
26 stg goto $(stg top) &&
27 test "$(echo $(stg top))" = "p5"
30 test_expect_success
'Attempt goto invalid patch' '
31 command_error stg goto p999 2>&1 |
32 grep -e "Patch \"p999\" does not exist"
35 test_expect_success
'Attempt goto invalid hash' '
36 command_error stg goto beeff00d 2>&1 |
37 grep -e "No patch associated with beeff00d"
40 test_expect_success
'Goto a patch' '
42 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
43 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p5"
46 test_expect_success
'Goto by partial sha1' '
47 stg goto "$(echo $(stg id p5) | test_copy_bytes 10)" &&
48 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4 p5" &&
49 stg goto "$(echo $(stg id p3))" &&
50 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
51 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p5"
54 test_expect_success
'Refuse to go to a hidden patch' '
55 stg new h0 -m "hidden patch" &&
57 command_error stg goto h0 2>&1 | grep -e "Cannot goto a hidden patch" &&
58 test "$(echo $(stg series --hidden --noprefix))" = "h0" &&
59 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
60 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p5"
63 test_expect_success
'Goto with merge check' '
64 stg goto --merged p5 &&
65 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4 p5" &&
66 test "$(echo $(stg series --unapplied --noprefix))" = ""
69 test_expect_success
'Goto with ambiguous patch substring' '
71 command_error stg goto p 2>&1 |
72 grep "Ambiguous patch name \"p\""