The eleventh batch
[git/gitster.git] / t / t3514-cherry-pick-revert-gpg.sh
blob133dc072178a161a33b05ca02f8872b5286a943a
1 #!/bin/sh
3 # Copyright (c) 2020 Doan Tran Cong Danh
6 test_description='test {cherry-pick,revert} --[no-]gpg-sign'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY/lib-gpg.sh"
12 if ! test_have_prereq GPG
13 then
14 skip_all='skip all test {cherry-pick,revert} --[no-]gpg-sign, gpg not available'
15 test_done
18 test_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
26 conf=$1
27 cmd=$2
28 cmit=$3
29 shift 3
30 test_expect_success "$cmd $* $cmit with commit.gpgsign=$conf $will sign commit" "
31 git reset --hard tip &&
32 git config commit.gpgsign $conf &&
33 git $cmd $* $cmit &&
34 git rev-list tip.. >rev-list &&
35 $must_fail git verify-commit \$(cat rev-list)
39 test_expect_success 'setup' '
40 test_commit one &&
41 git switch -c side &&
42 test_commit side1 &&
43 test_commit side2 &&
44 git switch - &&
45 test_commit two &&
46 test_commit three &&
47 test_commit tip
50 test_gpg_sign ! false cherry-pick side
51 test_gpg_sign ! false cherry-pick ..side
52 test_gpg_sign true cherry-pick side
53 test_gpg_sign true cherry-pick ..side
54 test_gpg_sign ! true cherry-pick side --no-gpg-sign
55 test_gpg_sign ! true cherry-pick ..side --no-gpg-sign
56 test_gpg_sign ! true cherry-pick side --gpg-sign --no-gpg-sign
57 test_gpg_sign ! true cherry-pick ..side --gpg-sign --no-gpg-sign
58 test_gpg_sign false cherry-pick side --no-gpg-sign --gpg-sign
59 test_gpg_sign false cherry-pick ..side --no-gpg-sign --gpg-sign
60 test_gpg_sign true cherry-pick side --edit
61 test_gpg_sign true cherry-pick ..side --edit
62 test_gpg_sign ! true cherry-pick side --edit --no-gpg-sign
63 test_gpg_sign ! true cherry-pick ..side --edit --no-gpg-sign
64 test_gpg_sign ! true cherry-pick side --edit --gpg-sign --no-gpg-sign
65 test_gpg_sign ! true cherry-pick ..side --edit --gpg-sign --no-gpg-sign
66 test_gpg_sign false cherry-pick side --edit --no-gpg-sign --gpg-sign
67 test_gpg_sign false cherry-pick ..side --edit --no-gpg-sign --gpg-sign
69 test_gpg_sign ! false revert HEAD --edit
70 test_gpg_sign ! false revert two.. --edit
71 test_gpg_sign true revert HEAD --edit
72 test_gpg_sign true revert two.. --edit
73 test_gpg_sign ! true revert HEAD --edit --no-gpg-sign
74 test_gpg_sign ! true revert two.. --edit --no-gpg-sign
75 test_gpg_sign ! true revert HEAD --edit --gpg-sign --no-gpg-sign
76 test_gpg_sign ! true revert two.. --edit --gpg-sign --no-gpg-sign
77 test_gpg_sign false revert HEAD --edit --no-gpg-sign --gpg-sign
78 test_gpg_sign false revert two.. --edit --no-gpg-sign --gpg-sign
79 test_gpg_sign true revert HEAD --no-edit
80 test_gpg_sign true revert two.. --no-edit
81 test_gpg_sign ! true revert HEAD --no-edit --no-gpg-sign
82 test_gpg_sign ! true revert two.. --no-edit --no-gpg-sign
83 test_gpg_sign ! true revert HEAD --no-edit --gpg-sign --no-gpg-sign
84 test_gpg_sign ! true revert two.. --no-edit --gpg-sign --no-gpg-sign
85 test_gpg_sign false revert HEAD --no-edit --no-gpg-sign --gpg-sign
87 test_done