git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Hook "post-merge" does not get executed in case of confilicts
@ 2014-08-21 18:51 Bertram Scharpf
  2014-08-21 19:07 ` Jonathan Nieder
  0 siblings, 1 reply; 2+ messages in thread
From: Bertram Scharpf @ 2014-08-21 18:51 UTC (permalink / raw)
  To: git

Hi,

today I wrote a port-merge hook. Then I just detected that it only gets
executed when the merge is immediately successful. In case there is a
conflict, I have to finish the merge using the command "git commit".
This will not call the post-merge hook.

I think the hook should be reliable to be executed on _every_ non-failed
merge. Therefore I propose the below extension.

Bertram


diff --git a/builtin/commit.c b/builtin/commit.c
index 5ed6036..6a8ee2d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1783,6 +1783,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	rerere(0);
 	run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
+	if (whence == FROM_MERGE)
+		run_hook_le(NULL, "post-merge", "0", NULL);
 	if (amend && !no_post_rewrite) {
 		struct notes_rewrite_cfg *cfg;
 		cfg = init_copy_notes_for_rewrite("amend");


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Hook "post-merge" does not get executed in case of confilicts
  2014-08-21 18:51 Hook "post-merge" does not get executed in case of confilicts Bertram Scharpf
@ 2014-08-21 19:07 ` Jonathan Nieder
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Nieder @ 2014-08-21 19:07 UTC (permalink / raw)
  To: Bertram Scharpf; +Cc: git

Hi,

Bertram Scharpf wrote:

> today I wrote a port-merge hook. Then I just detected that it only gets
> executed when the merge is immediately successful. In case there is a
> conflict, I have to finish the merge using the command "git commit".
> This will not call the post-merge hook.
>
> I think the hook should be reliable to be executed on _every_ non-failed
> merge. Therefore I propose the below extension.

I agree that at first glance this sounds like a good thing.  A manual
conflict resolution is not so different from a very smart merge
strategy, after all.

Nits:

> Bertram

Sign-off?  (See Documentation/SubmittingPatches, section 5 "Sign your
work" for what this means.

> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1783,6 +1783,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  
>  	rerere(0);
>  	run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
> +	if (whence == FROM_MERGE)
> +		run_hook_le(NULL, "post-merge", "0", NULL);

"git merge" doesn't run the post-commit hook, so there's a new
asymmetry being introduced here.  Should "git merge" run the
post-commit hook?  Should a "git commit" that means "git merge
--continue" avoid running it?

Also if doing this for real, the documentation should be updated
and tests introduced to make sure the behavior doesn't get broken
in the future.  Documentation/githooks.txt currently says

	This hook cannot affect the outcome of git merge and is not
	executed if the merge failed due to conflicts.

which would need to be updated to say that the hook will run later
in that case, when the merge is finally committed.

Thanks and hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-21 19:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 18:51 Hook "post-merge" does not get executed in case of confilicts Bertram Scharpf
2014-08-21 19:07 ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).