surround %s with quotes when failed to lookup commit
[git/debian.git] / t / t3514-cherry-pick-revert-gpg.sh
blob5b2e250eaa509458d89d13f4a3728276525fa746
1 #!/bin/sh
3 # Copyright (c) 2020 Doan Tran Cong Danh
6 test_description='test {cherry-pick,revert} --[no-]gpg-sign'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY/lib-gpg.sh"
11 if ! test_have_prereq GPG
12 then
13 skip_all='skip all test {cherry-pick,revert} --[no-]gpg-sign, gpg not available'
14 test_done
17 test_gpg_sign () {
18 local must_fail= will=will fake_editor=
19 if test "x$1" = "x!"
20 then
21 must_fail=test_must_fail
22 will="won't"
23 shift
25 conf=$1
26 cmd=$2
27 cmit=$3
28 shift 3
29 test_expect_success "$cmd $* $cmit with commit.gpgsign=$conf $will sign commit" "
30 git reset --hard tip &&
31 git config commit.gpgsign $conf &&
32 git $cmd $* $cmit &&
33 git rev-list tip.. >rev-list &&
34 $must_fail git verify-commit \$(cat rev-list)
38 test_expect_success 'setup' '
39 test_commit one &&
40 git switch -c side &&
41 test_commit side1 &&
42 test_commit side2 &&
43 git switch - &&
44 test_commit two &&
45 test_commit three &&
46 test_commit tip
49 test_gpg_sign ! false cherry-pick side
50 test_gpg_sign ! false cherry-pick ..side
51 test_gpg_sign true cherry-pick side
52 test_gpg_sign true cherry-pick ..side
53 test_gpg_sign ! true cherry-pick side --no-gpg-sign
54 test_gpg_sign ! true cherry-pick ..side --no-gpg-sign
55 test_gpg_sign ! true cherry-pick side --gpg-sign --no-gpg-sign
56 test_gpg_sign ! true cherry-pick ..side --gpg-sign --no-gpg-sign
57 test_gpg_sign false cherry-pick side --no-gpg-sign --gpg-sign
58 test_gpg_sign false cherry-pick ..side --no-gpg-sign --gpg-sign
59 test_gpg_sign true cherry-pick side --edit
60 test_gpg_sign true cherry-pick ..side --edit
61 test_gpg_sign ! true cherry-pick side --edit --no-gpg-sign
62 test_gpg_sign ! true cherry-pick ..side --edit --no-gpg-sign
63 test_gpg_sign ! true cherry-pick side --edit --gpg-sign --no-gpg-sign
64 test_gpg_sign ! true cherry-pick ..side --edit --gpg-sign --no-gpg-sign
65 test_gpg_sign false cherry-pick side --edit --no-gpg-sign --gpg-sign
66 test_gpg_sign false cherry-pick ..side --edit --no-gpg-sign --gpg-sign
68 test_gpg_sign ! false revert HEAD --edit
69 test_gpg_sign ! false revert two.. --edit
70 test_gpg_sign true revert HEAD --edit
71 test_gpg_sign true revert two.. --edit
72 test_gpg_sign ! true revert HEAD --edit --no-gpg-sign
73 test_gpg_sign ! true revert two.. --edit --no-gpg-sign
74 test_gpg_sign ! true revert HEAD --edit --gpg-sign --no-gpg-sign
75 test_gpg_sign ! true revert two.. --edit --gpg-sign --no-gpg-sign
76 test_gpg_sign false revert HEAD --edit --no-gpg-sign --gpg-sign
77 test_gpg_sign false revert two.. --edit --no-gpg-sign --gpg-sign
78 test_gpg_sign true revert HEAD --no-edit
79 test_gpg_sign true revert two.. --no-edit
80 test_gpg_sign ! true revert HEAD --no-edit --no-gpg-sign
81 test_gpg_sign ! true revert two.. --no-edit --no-gpg-sign
82 test_gpg_sign ! true revert HEAD --no-edit --gpg-sign --no-gpg-sign
83 test_gpg_sign ! true revert two.. --no-edit --gpg-sign --no-gpg-sign
84 test_gpg_sign false revert HEAD --no-edit --no-gpg-sign --gpg-sign
86 test_done