Better stack rename abstraction
[stgit.git] / t / t1003-new.sh
blob54661d984d374263bfad1a0f1a373cddd678c16d
1 #!/bin/sh
3 # Copyright (c) 2007 Karl Hasselström
6 test_description='Test "stg new".'
8 . ./test-lib.sh
10 test_expect_success \
11 'Initialize the StGIT repository' '
12 stg init
15 test_expect_success \
16 'Too many arguments' '
17 command_error stg new foo extra_arg 2>&1 |
18 grep -e "incorrect number of arguments"
21 test_expect_success \
22 'Create a named patch' '
23 stg new foo -m foobar &&
24 [ $(stg series --applied -c) -eq 1 ]
27 test_expect_success \
28 'Invalid patch name: space' '
29 command_error stg new "bad name" 2>&1 >/dev/null |
30 grep -e "Invalid patch name: \"bad name\""
33 test_expect_success \
34 'Invalid patch name: carat' '
35 command_error stg new "bad^name" 2>&1 >/dev/null |
36 grep -e "Invalid patch name: \"bad\^name\""
39 test_expect_success \
40 'Invalid patch name: empty' '
41 command_error stg new "" 2>&1 >/dev/null |
42 grep -e "Invalid patch name: \"\""
45 test_expect_success \
46 'Create a patch without giving a name' '
47 stg new -m yo &&
48 [ "$(echo $(stg top))" = "yo" ] &&
49 [ $(stg series --applied -c) -eq 2 ]
52 test_expect_success \
53 'Attempt to create patch with duplicate name' '
54 command_error stg new foo -m "duplicate foo" 2>&1 |
55 grep -e "foo: patch already exists"
58 test_expect_success \
59 'Attempt new with conflicts' '
60 stg new -m p0 &&
61 echo "something" > file.txt &&
62 stg add file.txt &&
63 stg refresh &&
64 stg new -m p1 &&
65 echo "something else" > file.txt &&
66 stg refresh &&
67 stg pop &&
68 stg new -m p2 &&
69 echo "something different" > file.txt &&
70 stg refresh &&
71 conflict stg push p1 &&
72 command_error stg new -m p3 2>&1 |
73 grep -e "Cannot create a new patch -- resolve conflicts first" &&
74 stg reset --hard
77 test_expect_success \
78 'Save template' '
79 stg new --save-template new-tmpl.txt &&
80 test_path_is_file new-tmpl.txt
83 test_expect_success \
84 'New with patchdescr.tmpl' '
85 echo "Patch Description Template" > .git/patchdescr.tmpl &&
86 stg new templated-patch &&
87 stg show | grep "Patch Description Template"
90 test_expect_failure \
91 'Patch with slash in name' '
92 stg new bar/foo -m "patch bar/foo"
95 test_done