git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Bertram Scharpf <lists@bertram-scharpf.de>
Cc: git@vger.kernel.org
Subject: Re: Hook "post-merge" does not get executed in case of confilicts
Date: Thu, 21 Aug 2014 12:07:16 -0700	[thread overview]
Message-ID: <20140821190716.GI20185@google.com> (raw)
In-Reply-To: <20140821185141.GA93319@becker.bs.l>

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

      reply	other threads:[~2014-08-21 19:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140821190716.GI20185@google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lists@bertram-scharpf.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).