3 # Copyright (c) 2020 Doan Tran Cong Danh
6 test_description='test rebase --[no-]gpg-sign'
9 . "$TEST_DIRECTORY/lib-rebase.sh"
10 . "$TEST_DIRECTORY/lib-gpg.sh"
12 if ! test_have_prereq GPG
14 skip_all='skip all test rebase --[no-]gpg-sign, gpg not available'
18 test_rebase_gpg_sign () {
19 local must_fail= will=will fake_editor=
22 must_fail=test_must_fail
28 test_expect_success "rebase $* with commit.gpgsign=$conf $will sign commit" "
30 git config commit.gpgsign $conf &&
32 FAKE_LINES='r 1 p 2' git rebase --force-rebase --root $* &&
33 $must_fail git verify-commit HEAD^ &&
34 $must_fail git verify-commit HEAD
38 test_expect_success 'setup' '
41 test_must_fail git verify-commit HEAD &&
42 test_must_fail git verify-commit HEAD^
45 test_expect_success 'setup: merge commit' '
46 test_commit fork-point &&
50 git merge --no-ff side &&
54 test_rebase_gpg_sign ! false
55 test_rebase_gpg_sign true
56 test_rebase_gpg_sign ! true --no-gpg-sign
57 test_rebase_gpg_sign ! true --gpg-sign --no-gpg-sign
58 test_rebase_gpg_sign false --no-gpg-sign --gpg-sign
59 test_rebase_gpg_sign true -i
60 test_rebase_gpg_sign ! true -i --no-gpg-sign
61 test_rebase_gpg_sign ! true -i --gpg-sign --no-gpg-sign
62 test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign
64 test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
65 git reset --hard merged &&
66 git config commit.gpgsign true &&
67 git rebase -p --no-gpg-sign --onto=one fork-point master &&
68 test_must_fail git verify-commit HEAD
71 test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' '
72 git reset --hard merged &&
73 test_unconfig commit.gpgsign &&
74 git rebase -fr --gpg-sign -s resolve --root &&
75 git verify-commit HEAD
78 test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
79 git reset --hard merged &&
80 git config commit.gpgsign true &&
81 git rebase -fr -s resolve --root &&
82 git verify-commit HEAD
85 test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
86 git reset --hard merged &&
87 git config commit.gpgsign false &&
88 git rebase -fr --gpg-sign -s resolve --root &&
89 git verify-commit HEAD
92 test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
93 git reset --hard merged &&
94 git config commit.gpgsign true &&
95 git rebase -fr --no-gpg-sign -s resolve --root &&
96 test_must_fail git verify-commit HEAD
99 test_expect_success 'rebase -r --gpg-sign will sign commit' '
100 git reset --hard merged &&
101 test_unconfig commit.gpgsign &&
102 git rebase -fr --gpg-sign --root &&
103 git verify-commit HEAD
106 test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' '
107 git reset --hard merged &&
108 git config commit.gpgsign true &&
109 git rebase -fr --root &&
110 git verify-commit HEAD
113 test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
114 git reset --hard merged &&
115 git config commit.gpgsign false &&
116 git rebase -fr --gpg-sign --root &&
117 git verify-commit HEAD
120 test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
121 git reset --hard merged &&
122 git config commit.gpgsign true &&
123 git rebase -fr --no-gpg-sign --root &&
124 test_must_fail git verify-commit HEAD