Tests redirect to err file when grepping stderr
[stgit.git] / t / t1006-branch-cleanup.sh
blob5d204d59f6dd73ad35274748751258f3d11c6d71
1 #!/bin/sh
3 test_description='Branch cleanup'
5 . ./test-lib.sh
7 test_expect_success 'Initialize branch' '
8 stg init &&
9 stg branch --create foo &&
10 echo "hello" > bar &&
11 stg add bar &&
12 stg new -m p0 &&
13 stg refresh
16 test_expect_success 'Cannot cleanup with patches' '
17 command_error stg branch --cleanup 2>err &&
18 grep "Cannot clean up: the series still contains patches" err
21 test_expect_success 'Cannot cleanup with unapplied patches' '
22 stg pop &&
23 command_error stg branch --cleanup 2>err &&
24 grep "Cannot clean up: the series still contains patches" err
27 test_expect_success 'Clone branch with patches' '
28 stg branch --clone foo2 &&
29 test "$(stg branch)" = "foo2" &&
30 test "$(stg series --noprefix --unapplied)" = "p0"
33 test_expect_success 'Force cleanup branch with patches' '
34 git config --get-regexp branch\\.foo2\\.stgit &&
35 stg branch --cleanup --force &&
36 test "$(stg series --noprefix --all)" = "" &&
37 command_error stg new -m p1 2>err &&
38 grep "branch not initialized" err &&
39 test_expect_code 1 git config --get-regexp branch\\.foo2\\.stgit
42 test_expect_success 'Commit patches' '
43 stg branch foo &&
44 stg push -a &&
45 stg commit -a
48 test_expect_success 'Invalid num args to cleanup' '
49 command_error stg branch --cleanup foo extra 2>err &&
50 grep "incorrect number of arguments" err
53 test_expect_success 'Cleanup current branch' '
54 stg branch --cleanup &&
55 test "$(stg branch)" = "foo" &&
56 command_error stg new -m p1 2>err &&
57 grep "branch not initialized" err
60 test_expect_success 'Re-initialize branch' '
61 stg init
64 test_expect_success 'Cleanup from another branch' '
65 stg branch master &&
66 stg branch --cleanup foo &&
67 test "$(stg branch)" = "master"
70 test_done