]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3435-rebase-gpg-sign.sh
strmap: enable allocations to come from a mem_pool
[thirdparty/git.git] / t / t3435-rebase-gpg-sign.sh
CommitLineData
c241371c
ĐTCD
1#!/bin/sh
2#
3# Copyright (c) 2020 Doan Tran Cong Danh
4#
5
6test_description='test rebase --[no-]gpg-sign'
7
8. ./test-lib.sh
9. "$TEST_DIRECTORY/lib-rebase.sh"
10. "$TEST_DIRECTORY/lib-gpg.sh"
11
12if ! test_have_prereq GPG
13then
14 skip_all='skip all test rebase --[no-]gpg-sign, gpg not available'
15 test_done
16fi
17
18test_rebase_gpg_sign () {
19 local must_fail= will=will fake_editor=
20 if test "x$1" = "x!"
21 then
22 must_fail=test_must_fail
23 will="won't"
24 shift
25 fi
26 conf=$1
27 shift
28 test_expect_success "rebase $* with commit.gpgsign=$conf $will sign commit" "
29 git reset two &&
30 git config commit.gpgsign $conf &&
31 set_fake_editor &&
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
35 "
36}
37
38test_expect_success 'setup' '
39 test_commit one &&
40 test_commit two &&
41 test_must_fail git verify-commit HEAD &&
42 test_must_fail git verify-commit HEAD^
43'
44
45test_expect_success 'setup: merge commit' '
46 test_commit fork-point &&
47 git switch -c side &&
48 test_commit three &&
49 git switch master &&
50 git merge --no-ff side &&
51 git tag merged
52'
53
54test_rebase_gpg_sign ! false
55test_rebase_gpg_sign true
56test_rebase_gpg_sign ! true --no-gpg-sign
57test_rebase_gpg_sign ! true --gpg-sign --no-gpg-sign
58test_rebase_gpg_sign false --no-gpg-sign --gpg-sign
59test_rebase_gpg_sign true -i
60test_rebase_gpg_sign ! true -i --no-gpg-sign
61test_rebase_gpg_sign ! true -i --gpg-sign --no-gpg-sign
62test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign
63
64test_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
69'
70
71test_done