Add --gpg-sign option in commit-tree, which was documented, but not
implemented, in 55ca3f99ae.

Signed-off-by: Brandon Richardson <[email protected]>
---

Thanks Martin for the tips and suggestions!

 builtin/commit-tree.c    | 8 +++++++-
 t/t7510-signed-commit.sh | 4 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 9ec36a82b..a51b2c8d7 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -66,7 +66,13 @@ int cmd_commit_tree(int argc, const char **argv, const char 
*prefix)
                        continue;
                }
 
-               if (skip_prefix(arg, "-S", &sign_commit))
+               if(!strcmp(arg, "--gpg-sign")) {
+                   skip_prefix(arg, "--gpg-sign", &sign_commit);
+                   continue;
+               }
+
+               if (skip_prefix(arg, "-S", &sign_commit) ||
+                       skip_prefix(arg, "--gpg-sign=", &sign_commit))
                        continue;
 
                if (!strcmp(arg, "--no-gpg-sign")) {
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 86d3f93fa..efc136eaf 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -51,7 +51,9 @@ test_expect_success GPG 'create signed commits' '
        # commit.gpgsign is still on but this must not be signed
        git tag ninth-unsigned $(echo 9 | git commit-tree HEAD^{tree}) &&
        # explicit -S of course must sign.
-       git tag tenth-signed $(echo 9 | git commit-tree -S HEAD^{tree})
+       git tag tenth-signed $(echo 10 | git commit-tree -S HEAD^{tree})
+       # --gpg-sign must sign.
+       git tag eleventh-signed $(echo 11 | git commit-tree --gpg-sign 
HEAD^{tree})
 '
 
 test_expect_success GPG 'verify and show signatures' '
-- 
2.20.1

Reply via email to