t3435: remove redundant test case
[git/debian.git] / t / t3435-rebase-gpg-sign.sh
blob6aa2aeb628d0eda991ee16760985f9017dceebb1
1 #!/bin/sh
3 # Copyright (c) 2020 Doan Tran Cong Danh
6 test_description='test rebase --[no-]gpg-sign'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 . ./test-lib.sh
12 . "$TEST_DIRECTORY/lib-rebase.sh"
13 . "$TEST_DIRECTORY/lib-gpg.sh"
15 if ! test_have_prereq GPG
16 then
17 skip_all='skip all test rebase --[no-]gpg-sign, gpg not available'
18 test_done
21 test_rebase_gpg_sign () {
22 local must_fail= will=will fake_editor=
23 if test "x$1" = "x!"
24 then
25 must_fail=test_must_fail
26 will="won't"
27 shift
29 conf=$1
30 shift
31 test_expect_success "rebase $* with commit.gpgsign=$conf $will sign commit" "
32 git reset two &&
33 git config commit.gpgsign $conf &&
34 set_fake_editor &&
35 FAKE_LINES='r 1 p 2' git rebase --force-rebase --root $* &&
36 $must_fail git verify-commit HEAD^ &&
37 $must_fail git verify-commit HEAD
41 test_expect_success 'setup' '
42 test_commit one &&
43 test_commit two &&
44 test_must_fail git verify-commit HEAD &&
45 test_must_fail git verify-commit HEAD^
48 test_expect_success 'setup: merge commit' '
49 test_commit fork-point &&
50 git switch -c side &&
51 test_commit three &&
52 git switch main &&
53 git merge --no-ff side &&
54 git tag merged
57 test_rebase_gpg_sign ! false
58 test_rebase_gpg_sign true
59 test_rebase_gpg_sign ! true --no-gpg-sign
60 test_rebase_gpg_sign ! true --gpg-sign --no-gpg-sign
61 test_rebase_gpg_sign false --no-gpg-sign --gpg-sign
62 test_rebase_gpg_sign true -i
63 test_rebase_gpg_sign ! true -i --no-gpg-sign
64 test_rebase_gpg_sign ! true -i --gpg-sign --no-gpg-sign
65 test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign
67 test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' '
68 git reset --hard merged &&
69 test_unconfig commit.gpgsign &&
70 git rebase -fr --gpg-sign -s resolve --root &&
71 git verify-commit HEAD
74 test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
75 git reset --hard merged &&
76 git config commit.gpgsign true &&
77 git rebase -fr -s resolve --root &&
78 git verify-commit HEAD
81 test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
82 git reset --hard merged &&
83 git config commit.gpgsign false &&
84 git rebase -fr --gpg-sign -s resolve --root &&
85 git verify-commit HEAD
88 test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
89 git reset --hard merged &&
90 git config commit.gpgsign true &&
91 git rebase -fr --no-gpg-sign -s resolve --root &&
92 test_must_fail git verify-commit HEAD
95 test_expect_success 'rebase -r --gpg-sign will sign commit' '
96 git reset --hard merged &&
97 test_unconfig commit.gpgsign &&
98 git rebase -fr --gpg-sign --root &&
99 git verify-commit HEAD
102 test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' '
103 git reset --hard merged &&
104 git config commit.gpgsign true &&
105 git rebase -fr --root &&
106 git verify-commit HEAD
109 test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
110 git reset --hard merged &&
111 git config commit.gpgsign false &&
112 git rebase -fr --gpg-sign --root &&
113 git verify-commit HEAD
116 test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
117 git reset --hard merged &&
118 git config commit.gpgsign true &&
119 git rebase -fr --no-gpg-sign --root &&
120 test_must_fail git verify-commit HEAD
123 test_done