Skip to content

Commit

Permalink
Merge branch 'jc/show-sig'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gitster committed Jan 6, 2012
2 parents 4a3a1ed + d041ffa commit 5de89d3
Show file tree
Hide file tree
Showing 16 changed files with 488 additions and 34 deletions.
4 changes: 0 additions & 4 deletions Documentation/RelNotes/1.7.9.txt
Expand Up @@ -99,10 +99,6 @@ Unless otherwise noted, all the fixes since v1.7.8 in the maintenance
releases are contained in this release (see release notes to them for
details).

* gitweb did not correctly fall back to configured $fallback_encoding
that is not 'latin1'.
(merge b13e3ea jn/maint-gitweb-utf8-fix later to maint).

--
exec >/var/tmp/1
O=v1.7.8.2-301-g48de656
Expand Down
11 changes: 11 additions & 0 deletions Documentation/config.txt
Expand Up @@ -1123,6 +1123,17 @@ grep.lineNumber::
grep.extendedRegexp::
If set to true, enable '--extended-regexp' option by default.

gpg.program::
Use this custom program instead of "gpg" found on $PATH when
making or verifying a PGP signature. The program must support the
same command line interface as GPG, namely, to verify a detached
signature, "gpg --verify $file - <$signature" is run, and the
program is expected to signal a good signature by exiting with
code 0, and to generate an ascii-armored detached signature, the
standard input of "gpg -bsau $key" is fed with the contents to be
signed, and the program is expected to send the result to its
standard output.

gui.commitmsgwidth::
Defines how wide the commit message window is in the
linkgit:git-gui[1]. "75" is the default.
Expand Down
8 changes: 5 additions & 3 deletions Documentation/git-tag.txt
Expand Up @@ -38,7 +38,9 @@ created (i.e. a lightweight tag).
A GnuPG signed tag object will be created when `-s` or `-u
<key-id>` is used. When `-u <key-id>` is not used, the
committer identity for the current user is used to find the
GnuPG key for signing.
GnuPG key for signing. The configuration variable `gpg.program`
is used to specify custom GnuPG binary.


OPTIONS
-------
Expand All @@ -48,11 +50,11 @@ OPTIONS

-s::
--sign::
Make a GPG-signed tag, using the default e-mail address's key
Make a GPG-signed tag, using the default e-mail address's key.

-u <key-id>::
--local-user=<key-id>::
Make a GPG-signed tag, using the given key
Make a GPG-signed tag, using the given key.

-f::
--force::
Expand Down
25 changes: 22 additions & 3 deletions builtin/commit-tree.c
Expand Up @@ -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)
{
Expand All @@ -25,19 +26,31 @@ 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;
struct commit_list *parents = NULL;
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")) {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 12 additions & 2 deletions builtin/commit.c
Expand Up @@ -26,6 +26,7 @@
#include "unpack-trees.h"
#include "quote.h"
#include "submodule.h"
#include "gpg-interface.h"

static const char * const builtin_commit_usage[] = {
"git commit [options] [--] <filepattern>...",
Expand Down Expand Up @@ -86,6 +87,8 @@ static int edit_flag = -1; /* unspecified */
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
static int no_post_rewrite, allow_empty_message;
static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
static char *sign_commit;

/*
* The default commit message cleanup mode will remove the lines
* beginning with # (shell comments) and leading and trailing
Expand Down Expand Up @@ -145,6 +148,8 @@ static struct option builtin_commit_options[] = {
OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"),
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, "key id",
"GPG sign commit", PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
/* end commit message options */

OPT_GROUP("Commit contents options"),
Expand Down Expand Up @@ -1325,6 +1330,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
static int git_commit_config(const char *k, const char *v, void *cb)
{
struct wt_status *s = cb;
int status;

if (!strcmp(k, "commit.template"))
return git_config_pathname(&template_file, k, v);
Expand All @@ -1333,6 +1339,9 @@ static int git_commit_config(const char *k, const char *v, void *cb)
return 0;
}

status = git_gpg_config(k, v, NULL);
if (status)
return status;
return git_status_config(k, v, s);
}

Expand Down Expand Up @@ -1486,14 +1495,15 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
}

if (amend) {
extra = read_commit_extra_headers(current_head);
const char *exclude_gpgsig[2] = { "gpgsig", NULL };
extra = read_commit_extra_headers(current_head, exclude_gpgsig);
} else {
struct commit_extra_header **tail = &extra;
append_merge_tag_headers(parents, &tail);
}

if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1,
author_ident.buf, extra)) {
author_ident.buf, sign_commit, extra)) {
rollback_index_files();
die(_("failed to write commit object"));
}
Expand Down
14 changes: 12 additions & 2 deletions builtin/merge.c
Expand Up @@ -27,6 +27,7 @@
#include "resolve-undo.h"
#include "remote.h"
#include "fmt-merge-msg.h"
#include "gpg-interface.h"

#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
Expand Down Expand Up @@ -64,6 +65,7 @@ static int allow_rerere_auto;
static int abort_current_merge;
static int show_progress = -1;
static int default_to_upstream;
static const char *sign_commit;

static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
Expand Down Expand Up @@ -209,6 +211,8 @@ static struct option builtin_merge_options[] = {
OPT_BOOLEAN(0, "abort", &abort_current_merge,
"abort the current in-progress merge"),
OPT_SET_INT(0, "progress", &show_progress, "force progress reporting", 1),
{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, "key id",
"GPG sign commit", PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
OPT_BOOLEAN(0, "overwrite-ignore", &overwrite_ignore, "update ignored files (default)"),
OPT_END()
};
Expand Down Expand Up @@ -571,7 +575,11 @@ static int git_merge_config(const char *k, const char *v, void *cb)
default_to_upstream = git_config_bool(k, v);
return 0;
}

status = fmt_merge_msg_config(k, v, cb);
if (status)
return status;
status = git_gpg_config(k, v, NULL);
if (status)
return status;
return git_diff_ui_config(k, v, cb);
Expand Down Expand Up @@ -910,7 +918,8 @@ static int merge_trivial(struct commit *head)
parent->next->item = remoteheads->item;
parent->next->next = NULL;
prepare_to_commit();
if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL))
if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL,
sign_commit))
die(_("failed to write commit object"));
finish(head, result_commit, "In-index merge");
drop_save();
Expand Down Expand Up @@ -942,7 +951,8 @@ static int finish_automerge(struct commit *head,
strbuf_addch(&merge_msg, '\n');
prepare_to_commit();
free_commit_list(remoteheads);
if (commit_tree(&merge_msg, result_tree, parents, result_commit, NULL))
if (commit_tree(&merge_msg, result_tree, parents, result_commit,
NULL, sign_commit))
die(_("failed to write commit object"));
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
finish(head, result_commit, buf.buf);
Expand Down

0 comments on commit 5de89d3

Please sign in to comment.