Re: git merge <tag>: Spawning an editor can't be disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]