[PATCH 10/10] merge: force edit mode when merging a tag object

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

 



Now that we allow pulling a tag from the remote site to validate the
authenticity, we should give the user the final chance to verify and
edit the merge message.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---

 * ... and finally.  Obviously this makes it necessary for the series to
   be applied on 3dfbe68 (Merge branch 'js/merge-edit-option', 2011-10-19)
   or newer.

 builtin/merge.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 48e7f00..6b63bbd 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -406,13 +406,15 @@ static void finish(struct commit *head_commit,
 	strbuf_release(&reflog_message);
 }
 
-static struct object *want_commit(const char *name)
+static struct object *want_commit(const char *name, enum object_type *real_type)
 {
 	struct object *obj;
 	unsigned char sha1[20];
 	if (get_sha1(name, sha1))
 		return NULL;
 	obj = parse_object(sha1);
+	if (real_type)
+		*real_type = obj->type;
 	return peel_to_type(name, 0, obj, OBJ_COMMIT);
 }
 
@@ -431,7 +433,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
 	remote = bname.buf;
 
 	memset(branch_head, 0, sizeof(branch_head));
-	remote_head = want_commit(remote);
+	remote_head = want_commit(remote, NULL);
 	if (!remote_head)
 		die(_("'%s' does not point to a commit"), remote);
 
@@ -1204,7 +1206,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		if (!allow_fast_forward)
 			die(_("Non-fast-forward commit does not make sense into "
 			    "an empty head"));
-		remote_head = want_commit(argv[0]);
+		remote_head = want_commit(argv[0], NULL);
 		if (!remote_head)
 			die(_("%s - not something we can merge"), argv[0]);
 		read_empty(remote_head->sha1, 0);
@@ -1253,8 +1255,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	for (i = 0; i < argc; i++) {
 		struct object *o;
 		struct commit *commit;
+		enum object_type real_type;
 
-		o = want_commit(argv[i]);
+		o = want_commit(argv[i], &real_type);
 		if (!o)
 			die(_("%s - not something we can merge"), argv[i]);
 		commit = lookup_commit(o->sha1);
@@ -1264,6 +1267,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		strbuf_addf(&buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
 		setenv(buf.buf, argv[i], 1);
 		strbuf_reset(&buf);
+		if (real_type == OBJ_TAG)
+			option_edit = 1;
 	}
 
 	if (!use_strategies) {
@@ -1321,7 +1326,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		if (have_message)
 			strbuf_addstr(&msg,
 				" (no commit created; -m option ignored)");
-		o = want_commit(sha1_to_hex(remoteheads->item->object.sha1));
+		o = want_commit(sha1_to_hex(remoteheads->item->object.sha1), NULL);
 		if (!o)
 			return 1;
 
-- 
1.7.8.rc0.108.g71b5ec

--
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]