diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-01-06 12:44:07 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-01-06 12:44:07 -0800 |
commit | 5de89d3abfca98b0dfd0280d28576940c913d60d (patch) | |
tree | ce339497e72abc84f4a1bbc9b270b07ab46dbc0c /builtin/commit-tree.c | |
parent | 4a3a1edd0be1c5254ae4fc66e06297d87ef7d530 (diff) | |
parent | d041ffa55a69cb6cdc3b160dc181c7e59b3bd4bb (diff) | |
download | git-5de89d3abfca98b0dfd0280d28576940c913d60d.tar.gz git-5de89d3abfca98b0dfd0280d28576940c913d60d.tar.xz |
Merge branch 'jc/show-sig'
* jc/show-sig:
log --show-signature: reword the common two-head merge case
log-tree: show mergetag in log --show-signature output
log-tree.c: small refactor in show_signature()
commit --amend -S: strip existing gpgsig headers
verify_signed_buffer: fix stale comment
gpg-interface: allow use of a custom GPG binary
pretty: %G[?GS] placeholders
test "commit -S" and "log --show-signature"
log: --show-signature
commit: teach --gpg-sign option
Conflicts:
builtin/commit-tree.c
builtin/commit.c
builtin/merge.c
notes-cache.c
pretty.c
Diffstat (limited to 'builtin/commit-tree.c')
-rw-r--r-- | builtin/commit-tree.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 05353c30f..164b655df 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -8,8 +8,9 @@ #include "tree.h" #include "builtin.h" #include "utf8.h" +#include "gpg-interface.h" -static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-m <message>] [-F <file>] <sha1> <changelog"; +static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S<signer>] [-m <message>] [-F <file>] <sha1> <changelog"; static void new_parent(struct commit *parent, struct commit_list **parents_p) { @@ -25,6 +26,14 @@ static void new_parent(struct commit *parent, struct commit_list **parents_p) commit_list_insert(parent, parents_p); } +static int commit_tree_config(const char *var, const char *value, void *cb) +{ + int status = git_gpg_config(var, value, NULL); + if (status) + return status; + return git_default_config(var, value, cb); +} + int cmd_commit_tree(int argc, const char **argv, const char *prefix) { int i, got_tree = 0; @@ -32,12 +41,16 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) unsigned char tree_sha1[20]; unsigned char commit_sha1[20]; struct strbuf buffer = STRBUF_INIT; + const char *sign_commit = NULL; - git_config(git_default_config, NULL); + git_config(commit_tree_config, NULL); if (argc < 2 || !strcmp(argv[1], "-h")) usage(commit_tree_usage); + if (get_sha1(argv[1], tree_sha1)) + die("Not a valid object name %s", argv[1]); + for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (!strcmp(arg, "-p")) { @@ -51,6 +64,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) continue; } + if (!memcmp(arg, "-S", 2)) { + sign_commit = arg + 2; + continue; + } + if (!strcmp(arg, "-m")) { if (argc <= ++i) usage(commit_tree_usage); @@ -98,7 +116,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) die_errno("git commit-tree: failed to read"); } - if (commit_tree(&buffer, tree_sha1, parents, commit_sha1, NULL)) { + if (commit_tree(&buffer, tree_sha1, parents, commit_sha1, + NULL, sign_commit)) { strbuf_release(&buffer); return 1; } |