All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Guido Günther" <agx@sigxcpu.org>, "Johannes Sixt" <j6t@kdbg.org>,
	git@vger.kernel.org
Subject: Re: git merge <tag>: Spawning an editor can't be disabled
Date: Thu, 9 Feb 2012 13:01:31 -0600	[thread overview]
Message-ID: <20120209190131.GG6249@burratino> (raw)
In-Reply-To: <7vzkcrx4f2.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:

> If the editor is not spawned, there is no way for the user to review the
> result of signature verification before deciding to accept the merge.
> "git merge --no-edit v1.7.2" could error out saying "you cannot create
> this merge without reviewing".  Or it could behave as if it was asked to
> "git merge --no-edit v1.7.2^0", dropping the signature verification and
> recording part altogether.

Others might want to read the tag message and check its signature,
even though the original committer was in a non-interactive rush.

Here's a toy patch (untested) to avoid wasting time verifying a
signature only to throw away the result.  It's not actually a no-op,
since if conflicts are encountered, the operator who intervenes won't
get to see whether the signature was valid when her editor of choice
is launched.

diff --git i/builtin.h w/builtin.h
index 857b9c8a..62dffbdc 100644
--- i/builtin.h
+++ w/builtin.h
@@ -17,6 +17,7 @@ extern void prune_packed_objects(int);
 
 struct fmt_merge_msg_opts {
 	unsigned add_title:1;
+	unsigned skip_tag_verification:1;
 	int shortlog_len;
 };
 
diff --git i/builtin/fmt-merge-msg.c w/builtin/fmt-merge-msg.c
index c81a7fef..e99030d3 100644
--- i/builtin/fmt-merge-msg.c
+++ w/builtin/fmt-merge-msg.c
@@ -316,7 +316,8 @@ static void fmt_tag_signature(struct strbuf *tagbuf,
 	strbuf_add_lines(tagbuf, "# ", sig->buf, sig->len);
 }
 
-static void fmt_merge_msg_sigs(struct strbuf *out)
+static void fmt_merge_msg_sigs(struct strbuf *out,
+			       struct fmt_merge_msg_opts *opts)
 {
 	int i, tag_number = 0, first_tag = 0;
 	struct strbuf tagbuf = STRBUF_INIT;
@@ -332,8 +333,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
 			goto next;
 		len = parse_signature(buf, size);
 
-		if (size == len)
-			; /* merely annotated */
+		if (size == len || opts->skip_tag_verification)
+			; /* merely annotated, or caller disabled signature check */
 		else if (verify_signed_buffer(buf, len, buf + len, size - len, &sig)) {
 			if (!sig.len)
 				strbuf_addstr(&sig, "gpg verification failed.\n");
@@ -400,7 +401,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
 		fmt_merge_msg_title(out, current_branch);
 
 	if (origins.nr)
-		fmt_merge_msg_sigs(out);
+		fmt_merge_msg_sigs(out, opts);
 
 	if (opts->shortlog_len) {
 		struct commit *head;
diff --git i/builtin/merge.c w/builtin/merge.c
index c401106e..75e027b6 100644
--- i/builtin/merge.c
+++ w/builtin/merge.c
@@ -1295,6 +1295,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			opts.add_title = !have_message;
 			opts.shortlog_len = shortlog_len;
 
+			assert(0 <= option_edit);
+			if (option_commit && !option_edit)
+				opts.skip_tag_verification = 1;
+
 			fmt_merge_msg(&merge_names, &merge_msg, &opts);
 			if (merge_msg.len)
 				strbuf_setlen(&merge_msg, merge_msg.len - 1);

  parent reply	other threads:[~2012-02-09 19:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120209153431.GA24033@godiug.sigxcpu.org>
2012-02-09 16:08 ` git merge <tag>: Spawning an editor can't be disabled Jonathan Nieder
2012-02-09 18:11   ` Junio C Hamano
2012-02-09 18:50     ` Johannes Sixt
2012-02-09 19:54       ` Junio C Hamano
2012-02-09 19:01     ` Jonathan Nieder [this message]
2012-02-09 21:20   ` Junio C Hamano
2012-02-09 21:34     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120209190131.GG6249@burratino \
    --to=jrnieder@gmail.com \
    --cc=agx@sigxcpu.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.