{"thread":{"id":"37395","subject":"Hook \"post-merge\" does not get executed in case of confilicts","startedAt":"2014-08-21T18:51:41Z","lastAt":"2014-08-21T19:07:16Z","messageCount":2,"participants":["Bertram Scharpf","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"248076","messageId":"20140821185141.GA93319@becker.bs.l","threadId":"37395","inReplyTo":null,"subject":"Hook \"post-merge\" does not get executed in case of confilicts","fromName":"Bertram Scharpf","fromEmail":"lists@bertram-scharpf.de","sentAt":"2014-08-21T18:51:41Z","receivedAt":"2014-08-21T18:51:41Z","isPatch":false,"sender":{"key":"lists@bertram-scharpf.de","avatar":null},"body":"Hi,\n\ntoday I wrote a port-merge hook. Then I just detected that it only gets\nexecuted when the merge is immediately successful. In case there is a\nconflict, I have to finish the merge using the command \"git commit\".\nThis will not call the post-merge hook.\n\nI think the hook should be reliable to be executed on _every_ non-failed\nmerge. Therefore I propose the below extension.\n\nBertram\n\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 5ed6036..6a8ee2d 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1783,6 +1783,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \n \trerere(0);\n \trun_commit_hook(use_editor, get_index_file(), \"post-commit\", NULL);\n+\tif (whence == FROM_MERGE)\n+\t\trun_hook_le(NULL, \"post-merge\", \"0\", NULL);\n \tif (amend && !no_post_rewrite) {\n \t\tstruct notes_rewrite_cfg *cfg;\n \t\tcfg = init_copy_notes_for_rewrite(\"amend\");\n\n\n-- \nBertram Scharpf\nStuttgart, Deutschland/Germany\nhttp://www.bertram-scharpf.de\n"},{"id":"248077","messageId":"20140821190716.GI20185@google.com","threadId":"37395","inReplyTo":"20140821185141.GA93319@becker.bs.l","subject":"Re: Hook \"post-merge\" does not get executed in case of confilicts","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-08-21T19:07:16Z","receivedAt":"2014-08-21T19:07:16Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nBertram Scharpf wrote:\n\n> today I wrote a port-merge hook. Then I just detected that it only gets\n> executed when the merge is immediately successful. In case there is a\n> conflict, I have to finish the merge using the command \"git commit\".\n> This will not call the post-merge hook.\n>\n> I think the hook should be reliable to be executed on _every_ non-failed\n> merge. Therefore I propose the below extension.\n\nI agree that at first glance this sounds like a good thing.  A manual\nconflict resolution is not so different from a very smart merge\nstrategy, after all.\n\nNits:\n\n> Bertram\n\nSign-off?  (See Documentation/SubmittingPatches, section 5 \"Sign your\nwork\" for what this means.\n\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1783,6 +1783,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n>  \n>  \trerere(0);\n>  \trun_commit_hook(use_editor, get_index_file(), \"post-commit\", NULL);\n> +\tif (whence == FROM_MERGE)\n> +\t\trun_hook_le(NULL, \"post-merge\", \"0\", NULL);\n\n\"git merge\" doesn't run the post-commit hook, so there's a new\nasymmetry being introduced here.  Should \"git merge\" run the\npost-commit hook?  Should a \"git commit\" that means \"git merge\n--continue\" avoid running it?\n\nAlso if doing this for real, the documentation should be updated\nand tests introduced to make sure the behavior doesn't get broken\nin the future.  Documentation/githooks.txt currently says\n\n\tThis hook cannot affect the outcome of git merge and is not\n\texecuted if the merge failed due to conflicts.\n\nwhich would need to be updated to say that the hook will run later\nin that case, when the merge is finally committed.\n\nThanks and hope that helps,\nJonathan\n"}]}