Subject: [PATCH v2 0/2] contrib/subtree: Add -S/-gpg-sign

From: "Patrik Weiskircher via GitGitGadget" <[email-masked]>
Date: Wed, 04 Jun 2025 14:16:35 +0000

This patch adds support for the -S/--gpg-sign option to the git subtree
command.

Currently, git subtree creates squash and merge commits without applying GPG
signatures, even when commit signing is configured via commit.gpgSign. This
causes issues in repositories that require signed commits for policy
reasons.

The implementation ensures that -S/--gpg-sign behaves consistently with
other Git commands, passing the flag through to git commit-tree and git
merge where appropriate.

This change improves compatibility with workflows and repositories that
enforce signed commits.

Changes have been made to this patch according to a discussion with Junio C
Hamano [email-masked] on my previous patch attempt.

Changes since v1:

 * Adjusted commit message to not mention the not implemented flag yet.

Patrik Weiskircher (2):
  contrib/subtree: parse using --stuck-long
  contrib/subtree: add -S/--gpg-sign

 contrib/subtree/git-subtree.adoc   |  19 +++--
 contrib/subtree/git-subtree.sh     |  66 ++++++++---------
 contrib/subtree/t/t7900-subtree.sh | 113 +++++++++++++++++++++++++++++
 3 files changed, 158 insertions(+), 40 deletions(-)

base-commit: 0bd2d791cc9f745ebaedafc0e1cbebdebe41343e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1928%2Fpweiskircher%2Fsubtree-sign-the-second-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1928/pweiskircher/subtree-sign-the-second-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1928

Range-diff vs v1:

 1:  fe7e918ba18 ! 1:  5bbdbf01636 contrib/subtree: parse using --stuck-long
     @@ Metadata
       ## Commit message ##
          contrib/subtree: parse using --stuck-long
      
     -    -S/--gpg-sign requires an optional parameter. Optional parameter
     -    handling only works unambiguous with git rev-parse --parseopt when using
     -    the --stuck-long option.
     +    Optional parameter handling only works unambiguous with git rev-parse
     +    --parseopt when using the --stuck-long option. To prepare for future commits
     +    which add flags with optional parameters, parse with --stuck-long.
      
          Signed-off-by: Patrik Weiskircher <[email-masked]>
      
 2:  45ae2c31bc0 = 2:  af5b4a65b63 contrib/subtree: add -S/--gpg-sign

-- 
gitgitgadget