git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 5, 2011, 06:01 UTC
Message-ID
<1320472900-6601-11-git-send-email-gitster@pobox.com>
In-Reply-To
<1320472900-6601-1-git-send-email-gitster@pobox.com>

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@pobox.com>
---
 * ... 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
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 13 of 32 in “Pulling signed tag”
  1. 00/10 Pulling signed tagJunio C Hamano, Nov 5, 2011
  2. 01/10 Split GPG interface into its own helper libraryJunio C Hamano, Nov 5, 2011
  3. 02/10 fetch: do not store peeled tag object names in FETCH_HEADJunio C Hamano, Nov 5, 2011
  4. 03/10 merge: notice local merging of tags and keep it unwrappedJunio C Hamano, Nov 5, 2011
  5. 04/10 fetch: allow "git fetch $there v1.0" to fetch a tagJunio C Hamano, Nov 5, 2011
  6. 05/10 tests: distinguish merges of tags and commitsJunio C Hamano, Nov 5, 2011
  7. 06/10 refs DWIMmery: use the same rule for both "git fetch" and othersJunio C Hamano, Nov 5, 2011
  8. 07/10 fmt-merge-msg: avoid early returnsJunio C Hamano, Nov 5, 2011
  9. 08/10 fmt-merge-msg: package options into a structureJunio C Hamano, Nov 5, 2011
  10. 09/10 fmt-merge-msg: Add contents of merged tag in the merge messageJunio C Hamano, Nov 5, 2011
  11. Johannes SixtNov 5, 2011
  12. Junio C HamanoNov 6, 2011
  13. 10/10 merge: force edit mode when merging a tag objectJunio C Hamano, Nov 5, 2011
  14. Nguyen Thai Ngoc DuyNov 5, 2011
  15. 00/12 Pulling signed/annotated tagsJunio C Hamano, Nov 8, 2011
  16. 01/12 Split GPG interface into its own helper libraryJunio C Hamano, Nov 8, 2011
  17. 02/12 fetch: do not store peeled tag object names in FETCH_HEADJunio C Hamano, Nov 8, 2011
  18. 03/12 merge: notice local merging of tags and keep it unwrappedJunio C Hamano, Nov 8, 2011
  19. 04/12 fetch: allow "git fetch $there v1.0" to fetch a tagJunio C Hamano, Nov 8, 2011
  20. 05/12 refs DWIMmery: use the same rule for both "git fetch" and othersJunio C Hamano, Nov 8, 2011
  21. 06/12 fmt-merge-msg: avoid early returnsJunio C Hamano, Nov 8, 2011
  22. 07/12 fmt-merge-msg: package options into a structureJunio C Hamano, Nov 8, 2011
  23. 08/12 fmt-merge-msg: Add contents of merged tag in the merge messageJunio C Hamano, Nov 8, 2011
  24. 09/12 merge: make usage of commit->util more extensibleJunio C Hamano, Nov 8, 2011
  25. 10/12 merge: record tag objects without peeling in MERGE_HEADJunio C Hamano, Nov 8, 2011
  26. 11/12 commit: copy merged signed tags to headers of merge commitJunio C Hamano, Nov 8, 2011
  27. 12/12 merge: force edit mode when merging a tag objectJunio C Hamano, Nov 8, 2011
  28. Linus TorvaldsNov 8, 2011
  29. Junio C HamanoNov 8, 2011
  30. Linus TorvaldsNov 8, 2011
  31. Junio C HamanoNov 8, 2011
  32. Junio C HamanoNov 8, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.