Allow usage of --gpg-sign flag in commit-tree builtin.
PATCH 1/1 Allow usage of --gpg-sign flag in commit-tree builtin.
---
Hi,
This is my first contribution, so please bear with me. All feedback is appreciated.
Ran into this issue while writing a signed commit object manually. Here are the steps I followed to replicate the issue:
mkdir test && cd test
git init
echo 'test' > test.txt
git hash-object -w test.txt
git update-index --add --cacheinfo 100644 <blob hash> test.txt git write-tree
git commit-tree --gpg-sign -m 'test commit msg' <tree obj hash>
Thanks,
Brandon
builtin/commit-tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
builtin/commit-tree.c +3 -1
@@ -66,7 +66,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)continue ; } -if (skip_prefix (arg,"-S" , &sign_commit)) +if (skip_prefix (arg,"-S" , &sign_commit) || +skip_prefix (arg,"--gpg-sign=" , &sign_commit) || +skip_prefix (arg,"--gpg-sign" , &sign_commit))continue ;if (!strcmp (arg,"--no-gpg-sign" )) {
Signature · 1 line
2.20.1
Hi Brandon,
Welcome to the list! :-)
Quoted 1 line · Brandon Richardson
Subject: [PATCH] Allow usage of --gpg-sign flag in commit-tree builtin.
Good find!
Maybe "commit-tree: handle --gpg-sign" which looks more like what we see in git log --oneline builtin/commit-tree.c.
Quoted 1 line
Signed-off-by Brandon Richardson <[email protected]>
It could be worthwhile to note in the proposed commit message that this option is actually documented, since 55ca3f99ae ("commit-tree: add and document --no-gpg-sign", 2013-12-13), so it's clearly an omission that it's not implemented.
Quoted 9 lines
Here are the steps I followed to replicate the issue:
mkdir test && cd test
git init
echo 'test' > test.txt
git hash-object -w test.txt
git update-index --add --cacheinfo 100644 <blob hash> test.txt git write-tree
git commit-tree --gpg-sign -m 'test commit msg' <tree obj hash>
Have you looked at turning this into a test in the t/ directory? Grepping a little suggests that t7510-signed-commit.sh might be a good spot. A test would make the patch more obviously correct, and would make sure that this doesn't regress in the future.
builtin/commit-tree.c int cmd_commit_tree(int argc, const char **argv, const char *prefix) · line 72
Quoted 5 lines
builtin/commit-tree.c +3
-1-if (skip_prefix (arg,"-S" , &sign_commit)) +if (skip_prefix (arg,"-S" , &sign_commit) || +skip_prefix (arg,"--gpg-sign=" , &sign_commit) || +skip_prefix (arg,"--gpg-sign" , &sign_commit))continue ;
This would match "--gpg-signfoo", which seems like a bug. The first two skip_prefix() calls look ok. Then maybe
if (!strcmp(arg, "--gpg-sign")) {
sign_commit = "";
continue;
}That's entirely untested, though.
Thanks for looking into this, rather than just side-stepping it. ;-)
Martin