Preserve picked patch name when possible
[stgit.git] / t / t2900-rename.sh
blobf22391778d37ebe210417436a9f24aefc5e5b6a5
1 #!/bin/sh
3 # Copyright (c) 2008 Onno Kortmann
4 # Parts taken from the other test scripts
5 # in this directory.
8 test_description='stg rename test
10 Tests some parts of the stg rename command.'
12 . ./test-lib.sh
13 stg init
15 test_expect_success 'Rename in empty' '
16 command_error stg rename foo 2>err &&
17 grep -e "No applied top patch to rename exists" err
20 test_expect_success 'Rename single top-most' '
21 stg new -m foo &&
22 stg rename bar
24 # bar
26 test_expect_success 'Rename non-existing' '
27 command_error stg rename neithersuchpatch norsuchpatch
30 test_expect_success 'Rename with two arguments' '
31 stg new -m baz &&
32 stg rename bar foo
34 # foo,baz
36 test_expect_success 'Rename with too many arguments' '
37 command_error stg rename foo bar baz 2>err &&
38 grep -e "incorrect number of arguments" err
41 test_expect_success 'Rename to existing name' '
42 command_error stg rename foo baz 2>err &&
43 grep -e "Patch already exists: \"baz\"" err
46 test_expect_success 'Rename to same name' '
47 command_error stg rename foo foo 2>err &&
48 grep -e "New patch name same as old: \"foo\"" err
51 test_expect_success 'Rename top-most when others exist' '
52 stg rename bar
55 test_expect_success 'Rename to invalid patch name: space' '
56 command_error stg rename bar "bar fo" 2>err &&
57 grep -e "Invalid patch name: \"bar fo\"" err
60 test_expect_success 'Rename to invalid patch name: colon' '
61 command_error stg rename bar "bar:fo" 2>err &&
62 grep -e "Invalid patch name: \"bar:fo\"" err
65 test_expect_failure 'Rename to patch name with slash' '
66 stg rename bar bar/fo &&
67 stg rename bar/fo bar
70 test_expect_success 'Rename hidden' '
71 stg pop &&
72 stg hide bar &&
73 stg rename bar pub &&
74 test "$(echo $(stg series --all))" = "> foo ! pub"
77 test_done