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

Re: [PATCH] Teach merge the '[-e|--edit]' option

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 7, 2011, 17:30 UTC
Message-ID
<7vk48gwvyd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1318001347-11347-1-git-send-email-jaysoffian@gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 17 quoted lines
> Implement "git merge [-e|--edit]" as "git merge --no-commit && git commit"
> as a convenience for the user.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> ...
> @@ -1447,6 +1457,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	if (merge_was_ok) {
> +		if (option_edit) {
> +			const char *args[] = {"commit", "-e", NULL};
> +			return run_command_v_opt(args, RUN_GIT_CMD);
> +		}
>  		fprintf(stderr, _("Automatic merge went well; "
>  			"stopped before committing as requested\n"));
>  		return 0;

I wanted to like this approach, thinking this approach might be safer and with the least chance of breaking other codepaths, but this feels like an ugly hack.

Are we still honoring all the hooks "git merge" honors? More importantly, isn't this make it impossible for future maintainers of this command to enhance the command by adding other hooks after the commit is made?

If we wanted to do this properly, we should update builtin/merge.c to call launch_editor() before it runs commit_tree(), in a way similar to how prepare_to_commit() in builtin/commit.c does so when e.g. "commit -m foo -e" is run. An editmsg is prepared (you already have it in MERGE_MSG), the editor is allowed to update it, and then the original code before such a patch will run using the updated contents of MERGE_MSG. That way, the _only_ change in behaviour when "-e" is used is to let the user update the message used in the commit log, and everything else would run exactly the same way as if no "-e" was given, including the invocation of hooks.

Previous: Jay SoffianNext: Jay Soffian
Message 2 of 15 in “Teach merge the '[-e|--edit]' option”
  1. Teach merge the '[-e|--edit]' optionJay Soffian, Oct 7, 2011
  2. Junio C HamanoOct 7, 2011
  3. Jay SoffianOct 7, 2011
  4. Junio C HamanoOct 7, 2011
  5. Jay SoffianOct 7, 2011
  6. Jay SoffianOct 7, 2011
  7. Junio C HamanoOct 7, 2011
  8. Teach merge the '[-e|--edit]' optionJay Soffian, Oct 7, 2011
  9. Junio C HamanoOct 7, 2011
  10. Jay SoffianOct 8, 2011
  11. Junio C HamanoOct 9, 2011
  12. Junio C HamanoOct 10, 2011
  13. Jakub NarebskiOct 10, 2011
  14. Matthieu MoyOct 10, 2011
  15. Junio C HamanoOct 10, 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.