git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] merge: Run commit-msg hook
@ 2016-07-26  7:48 Orgad Shaneh
  2016-07-26 13:02 ` Johannes Schindelin
  0 siblings, 1 reply; 8+ messages in thread
From: Orgad Shaneh @ 2016-07-26  7:48 UTC (permalink / raw)
  To: git; +Cc: Orgad Shaneh

From: Orgad Shaneh <orgads@gmail.com>

commit-msg is needed to either validate the commit message or edit it.
Gerrit for instance uses this hook to append its Change-Id footer.

This is relevant to merge commit just like any other commit.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
 Documentation/git-merge.txt | 6 +++++-
 builtin/merge.c             | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index b758d55..59508aa 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
 	[-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
-	[--[no-]allow-unrelated-histories]
+	[--[no-]allow-unrelated-histories] [--no-verify]
 	[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
 'git merge' <msg> HEAD <commit>...
 'git merge' --abort
@@ -87,6 +87,10 @@ invocations. The automated message can include the branch description.
 	Allow the rerere mechanism to update the index with the
 	result of auto-conflict resolution if possible.
 
+--no-verify::
+	This option bypasses the commit-msg hook.
+	See also linkgit:githooks[5].
+
 --abort::
 	Abort the current conflict resolution process, and
 	try to reconstruct the pre-merge state.
diff --git a/builtin/merge.c b/builtin/merge.c
index b555a1b..30c03c8 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -51,7 +51,7 @@ static const char * const builtin_merge_usage[] = {
 static int show_diffstat = 1, shortlog_len = -1, squash;
 static int option_commit = 1;
 static int option_edit = -1;
-static int allow_trivial = 1, have_message, verify_signatures;
+static int allow_trivial = 1, have_message, verify_signatures, no_verify;
 static int overwrite_ignore = 1;
 static struct strbuf merge_msg = STRBUF_INIT;
 static struct strategy **use_strategies;
@@ -228,6 +228,7 @@ static struct option builtin_merge_options[] = {
 	{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
 	  N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
 	OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
+	OPT_BOOL(0, "no-verify", &no_verify, N_("bypass commit-msg hook")),
 	OPT_END()
 };
 
@@ -809,6 +810,10 @@ static void prepare_to_commit(struct commit_list *remoteheads)
 		if (launch_editor(git_path_merge_msg(), NULL, NULL))
 			abort_commit(remoteheads, NULL);
 	}
+	if (!no_verify &&
+	    run_commit_hook(0 < option_edit, get_index_file(), "commit-msg",
+			    git_path_merge_msg(), NULL))
+		abort_commit(remoteheads, NULL);
 	read_merge_msg(&msg);
 	strbuf_stripspace(&msg, 0 < option_edit);
 	if (!msg.len)
-- 
2.8.2


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

* Re: [PATCH] merge: Run commit-msg hook
  2016-07-26  7:48 [PATCH] merge: Run commit-msg hook Orgad Shaneh
@ 2016-07-26 13:02 ` Johannes Schindelin
  2016-07-26 13:50   ` Orgad Shaneh
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2016-07-26 13:02 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: git

Hi Orgad,

On Tue, 26 Jul 2016, Orgad Shaneh wrote:

> From: Orgad Shaneh <orgads@gmail.com>

Again, this is unnecessary if you already send the mail from the same
address.

> commit-msg is needed to either validate the commit message or edit it.
> Gerrit for instance uses this hook to append its Change-Id footer.
> 
> This is relevant to merge commit just like any other commit.

Hmm. This is not very convincing to me, as

- if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?

- a merge is a different beast from a simple commit. That is why we have
  two different commands for them. A hook to edit the merge message may
  need to know the *second* parent commit, too, for example to generate
  a diffstat, or to add information about changes in an "evil commit".

- if Gerrit is the intended user, would it not make more sense to
  introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
  have to teach Gerrit a new trick anyway?

- if Gerrit is the intended user, why does it not simply edit the merge
  message itself? After all, it executes it, and probably crafts a merge
  message mentioning that this is an automatic merge, anyway, so why not
  add the Change-Id *then*?

Ciao,
Dscho

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

* Re: [PATCH] merge: Run commit-msg hook
  2016-07-26 13:02 ` Johannes Schindelin
@ 2016-07-26 13:50   ` Orgad Shaneh
  2016-07-26 14:54     ` Johannes Schindelin
  2016-07-26 21:05     ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Orgad Shaneh @ 2016-07-26 13:50 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Hi,

On Tue, Jul 26, 2016 at 4:02 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi Orgad,
>
> On Tue, 26 Jul 2016, Orgad Shaneh wrote:
>
>> From: Orgad Shaneh <orgads@gmail.com>
>
> Again, this is unnecessary if you already send the mail from the same
> address.
>
>> commit-msg is needed to either validate the commit message or edit it.
>> Gerrit for instance uses this hook to append its Change-Id footer.
>>
>> This is relevant to merge commit just like any other commit.
>
> Hmm. This is not very convincing to me, as
>
> - if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?

prepare-commit-msg is already called, a few lines above this addition.

>
> - a merge is a different beast from a simple commit. That is why we have
>   two different commands for them. A hook to edit the merge message may
>   need to know the *second* parent commit, too, for example to generate
>   a diffstat, or to add information about changes in an "evil commit".

That is correct for a post-merge hook. Why should *message validation* differ
between simple and merge commit?

> - if Gerrit is the intended user, would it not make more sense to
>   introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
>   have to teach Gerrit a new trick anyway?

Why is that new? Every commit in gerrit has a Change-Id footer, which is
generated by commit-msg hook. What I currently do for merges that succeed
without conflicts is unconditional commit --amend --no-edit just to
run the hook.
This doesn't make sense.

> - if Gerrit is the intended user, why does it not simply edit the merge
>   message itself? After all, it executes it, and probably crafts a merge
>   message mentioning that this is an automatic merge, anyway, so why not
>   add the Change-Id *then*?

Most Gerrit setups require Change-Id in the commit message that the user
pushes. It is possible to disable this setting, and then you don't need the
Change-Id at all, but then you can't push a new patch set for the change
(unless you copy the Change-Id from gerrit to your commit message).
That's a real pain, I'm not aware of any public gerrit server that
disables this :)

> Ciao,
> Dscho

- Orgad

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

* Re: [PATCH] merge: Run commit-msg hook
  2016-07-26 13:50   ` Orgad Shaneh
@ 2016-07-26 14:54     ` Johannes Schindelin
  2016-07-26 21:12       ` Junio C Hamano
       [not found]       ` <CAGHpTBLN1vBv12fSBXK0taGzxynMymBWRu8FcG=miBy=raReHw@mail.gmail.com>
  2016-07-26 21:05     ` Junio C Hamano
  1 sibling, 2 replies; 8+ messages in thread
From: Johannes Schindelin @ 2016-07-26 14:54 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: git

Hi Orgad,

On Tue, 26 Jul 2016, Orgad Shaneh wrote:

> On Tue, Jul 26, 2016 at 4:02 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Tue, 26 Jul 2016, Orgad Shaneh wrote:
> >
> >> commit-msg is needed to either validate the commit message or edit it.
> >> Gerrit for instance uses this hook to append its Change-Id footer.
> >>
> >> This is relevant to merge commit just like any other commit.
> >
> > Hmm. This is not very convincing to me, as
> >
> > - if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?
> 
> prepare-commit-msg is already called, a few lines above this addition.

Oh. That would have made a heck of a convincing argument in the commit
message. Pity it was not mentioned. (Yes, please read that as a strong
suggestion to fix that in the next patch iteration.)

FWIW I dug out the original submission:
http://thread.gmane.org/gmane.comp.version-control.git/151297/focus=151435

It seems that there was no discussion about the commit-msg. Which makes me
wonder why nobody thought of this.

Now, you could make a case that you want to run the commit-msg hook in the
same spirit as prepare-commit-msg (and mention that apparently nobody
thought of that when the patch was accepted into builtin/merge.c).

But then I wonder what your argument would be for *not* running the
pre-commit and the post-commit hooks in `git merge` as well?

Seems like a big inconsistency to me, one that would not be helped by a
piecemeal patch that does only half the job of resolving the inconsistency.

There was actually a question why the post-commit hook was not run in `git
merge`:
http://thread.gmane.org/gmane.comp.version-control.git/168716/focus=168773
(but it seems nobody cared all that much).

> > - a merge is a different beast from a simple commit. That is why we
> > have two different commands for them. A hook to edit the merge message
> > may need to know the *second* parent commit, too, for example to
> > generate a diffstat, or to add information about changes in an "evil
> > commit".
> 
> That is correct for a post-merge hook. Why should *message validation*
> differ between simple and merge commit?

You yourself do not use the hook for validation. You use it to *edit* the
message. My examples do the very same thing. Why should they wait for a
*post-merge* hook to amend the message?

Otherwise, why wouldn't you use the post-merge hook to add the Change-Id:
in your use case, too...

> > - if Gerrit is the intended user, would it not make more sense to
> >   introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
> >   have to teach Gerrit a new trick anyway?
> 
> Why is that new? Every commit in gerrit has a Change-Id footer, which is
> generated by commit-msg hook.

So it already works for Gerrit? Why is this patch needed, then? This is
confusing.

> What I currently do for merges that succeed without conflicts is
> unconditional commit --amend --no-edit just to run the hook.

So you do that manually? Or you taught Gerrit to do that? Please clarify.

> > - if Gerrit is the intended user, why does it not simply edit the merge
> >   message itself? After all, it executes it, and probably crafts a merge
> >   message mentioning that this is an automatic merge, anyway, so why not
> >   add the Change-Id *then*?
> 
> Most Gerrit setups require Change-Id in the commit message that the user
> pushes. It is possible to disable this setting, and then you don't need the
> Change-Id at all, but then you can't push a new patch set for the change
> (unless you copy the Change-Id from gerrit to your commit message).
> That's a real pain, I'm not aware of any public gerrit server that
> disables this :)

Forgive me, I never used Gerrit, and neither do I intend to do so.

I would appreciate a self-contained commit message that explains just
enough about Gerrit to understand what the patch tries to solve, and in a
manner such that even developers who decided to ignore Gerrit understand.

Ciao,
Dscho

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

* [PATCH] merge: Run commit-msg hook
@ 2016-07-26 15:32 Orgad Shaneh
  0 siblings, 0 replies; 8+ messages in thread
From: Orgad Shaneh @ 2016-07-26 15:32 UTC (permalink / raw)
  To: git

Hi again,

On Tue, Jul 26, 2016 at 5:54 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Orgad,
>
> On Tue, 26 Jul 2016, Orgad Shaneh wrote:
>
> > On Tue, Jul 26, 2016 at 4:02 PM, Johannes Schindelin
> > <Johannes.Schindelin@gmx.de> wrote:
> > >
> > > On Tue, 26 Jul 2016, Orgad Shaneh wrote:
> > >
> > >> commit-msg is needed to either validate the commit message or edit it.
> > >> Gerrit for instance uses this hook to append its Change-Id footer.
> > >>
> > >> This is relevant to merge commit just like any other commit.
> > >
> > > Hmm. This is not very convincing to me, as
> > >
> > > - if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?
> >
> > prepare-commit-msg is already called, a few lines above this addition.
>
> Oh. That would have made a heck of a convincing argument in the commit
> message. Pity it was not mentioned. (Yes, please read that as a strong
> suggestion to fix that in the next patch iteration.)


Done.

>
>
> FWIW I dug out the original submission:
> http://thread.gmane.org/gmane.comp.version-control.git/151297/focus=151435
>
> It seems that there was no discussion about the commit-msg. Which makes me
> wonder why nobody thought of this.
>
> Now, you could make a case that you want to run the commit-msg hook in the
> same spirit as prepare-commit-msg (and mention that apparently nobody
> thought of that when the patch was accepted into builtin/merge.c).
>
> But then I wonder what your argument would be for *not* running the
> pre-commit and the post-commit hooks in `git merge` as well?
>
> Seems like a big inconsistency to me, one that would not be helped by a
> piecemeal patch that does only half the job of resolving the inconsistency.
>
> There was actually a question why the post-commit hook was not run in `git
> merge`:
> http://thread.gmane.org/gmane.comp.version-control.git/168716/focus=168773
> (but it seems nobody cared all that much).


pre-commit seems to have been rejected, though I must admit I don't
fully understand why.
post-commit might make sense, but I wouldn't include it in the same
patch. These are
different issues.

>
> > > - a merge is a different beast from a simple commit. That is why we
> > > have two different commands for them. A hook to edit the merge message
> > > may need to know the *second* parent commit, too, for example to
> > > generate a diffstat, or to add information about changes in an "evil
> > > commit".
> >
> > That is correct for a post-merge hook. Why should *message validation*
> > differ between simple and merge commit?
>
> You yourself do not use the hook for validation. You use it to *edit* the
> message. My examples do the very same thing. Why should they wait for a
> *post-merge* hook to amend the message?


Because commit-msg doesn't know anything about the commit. It only refers
to the message. The commit might even not exist when it is called. If you
need data from the commit, post-merge is the right place.

>
> Otherwise, why wouldn't you use the post-merge hook to add the Change-Id:
> in your use case, too...
>
> > > - if Gerrit is the intended user, would it not make more sense to
> > >   introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
> > >   have to teach Gerrit a new trick anyway?
> >
> > Why is that new? Every commit in gerrit has a Change-Id footer, which is
> > generated by commit-msg hook.
>
> So it already works for Gerrit? Why is this patch needed, then? This is
> confusing.


Gerrit is a server, the user installs a commit-msg hook provided by
Gerrit on the local machine.
This hook currently works only for simple commits and not for
(trivial) merge commits.
That's where this patch comes to the rescue.

>
> > What I currently do for merges that succeed without conflicts is
> > unconditional commit --amend --no-edit just to run the hook.
>
> So you do that manually? Or you taught Gerrit to do that? Please clarify.


Gerrit can't do anything on my machine. It's a web/ssh server. I have my own
post-merge hook that runs commit --amend

> > > - if Gerrit is the intended user, why does it not simply edit the merge
> > >   message itself? After all, it executes it, and probably crafts a merge
> > >   message mentioning that this is an automatic merge, anyway, so why not
> > >   add the Change-Id *then*?
> >
> > Most Gerrit setups require Change-Id in the commit message that the user
> > pushes. It is possible to disable this setting, and then you don't need the
> > Change-Id at all, but then you can't push a new patch set for the change
> > (unless you copy the Change-Id from gerrit to your commit message).
> > That's a real pain, I'm not aware of any public gerrit server that
> > disables this :)
>
> Forgive me, I never used Gerrit, and neither do I intend to do so.

Too bad, great system :)

> I would appreciate a self-contained commit message that explains just
> enough about Gerrit to understand what the patch tries to solve, and in a
> manner such that even developers who decided to ignore Gerrit understand.


I hope it's better now. Thanks for your comments.

- Orgad

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

* Re: [PATCH] merge: Run commit-msg hook
  2016-07-26 13:50   ` Orgad Shaneh
  2016-07-26 14:54     ` Johannes Schindelin
@ 2016-07-26 21:05     ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2016-07-26 21:05 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: Johannes Schindelin, git

Orgad Shaneh <orgads@gmail.com> writes:

>> Hmm. This is not very convincing to me, as
>>
>> - if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?
>
> prepare-commit-msg is already called, a few lines above this addition.

I do not see such call in contrib/example/git-merge.sh; could it be
a recent bug that it calls it?

>> - a merge is a different beast from a simple commit. That is why we have
>>   two different commands for them. A hook to edit the merge message may
>>   need to know the *second* parent commit, too, for example to generate
>>   a diffstat, or to add information about changes in an "evil commit".
>
> That is correct for a post-merge hook. Why should *message validation* differ
> between simple and merge commit?

Have you seen a typical merge commit message?  They certainly look
different to me and different rules would apply.

>> - if Gerrit is the intended user, would it not make more sense to
>>   introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
>>   have to teach Gerrit a new trick anyway?
>
> Why is that new? Every commit in gerrit has a Change-Id footer, which is
> generated by commit-msg hook.

Hmm, I didn't know Gerrit gave Change-ID to merges.

In any case, I would think this is completely new.  Without this
change, commit-msg was not called for merges, so Gerrit wouldn't
have added Change-ID to merges with that mechanism.

A new merge-msg hook would make more sense, if we were making any
change.  I do not want to get yelled at by those who wrote their
commit-msg hooks long time ago and have happily been using them that
updated Git started calling them for their merges where their
validation logic for their single-parent commit do not apply at all.

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

* Re: [PATCH] merge: Run commit-msg hook
  2016-07-26 14:54     ` Johannes Schindelin
@ 2016-07-26 21:12       ` Junio C Hamano
       [not found]       ` <CAGHpTBLN1vBv12fSBXK0taGzxynMymBWRu8FcG=miBy=raReHw@mail.gmail.com>
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2016-07-26 21:12 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Orgad Shaneh, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> FWIW I dug out the original submission:
> http://thread.gmane.org/gmane.comp.version-control.git/151297/focus=151435
>
> It seems that there was no discussion about the commit-msg. Which makes me
> wonder why nobody thought of this.

I actually think it was a mistaken argument.

We could have devised a mechanism to prevent "git commit" that
concludes a conflicted "git merge" from calling the hook to resolve
the inconsistency, and the solution would have been equally valid.

I'd rather not make things worse by repeating that same mistake.  If
we were to change anything, we should be adding prepare-merge-msg as
you suggested earlier and weaning people off of the current
behaviour that was added by mistake.

Thanks.


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

* Re: [PATCH] merge: Run commit-msg hook
       [not found]       ` <CAGHpTBLN1vBv12fSBXK0taGzxynMymBWRu8FcG=miBy=raReHw@mail.gmail.com>
@ 2016-07-27 12:35         ` Johannes Schindelin
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2016-07-27 12:35 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: git

Hi Orgad,

On Tue, 26 Jul 2016, Orgad Shaneh wrote:

> On Tue, Jul 26, 2016 at 5:54 PM, Johannes Schindelin <
> Johannes.Schindelin@gmx.de> wrote:
> 
> > On Tue, 26 Jul 2016, Orgad Shaneh wrote:
> >
> > > On Tue, Jul 26, 2016 at 4:02 PM, Johannes Schindelin
> > > <Johannes.Schindelin@gmx.de> wrote:
> > > >
> > > > On Tue, 26 Jul 2016, Orgad Shaneh wrote:
> > > >
> > > >> commit-msg is needed to either validate the commit message or
> > > >> edit it.  Gerrit for instance uses this hook to append its
> > > >> Change-Id footer.
> > > >>
> > > >> This is relevant to merge commit just like any other commit.
> > > >
> > > > Hmm. This is not very convincing to me, as
> > > >
> > > > - if you call commit-msg in `git merge` now, why not
> > `prepare-commit-msg`?
> > >
> > > prepare-commit-msg is already called, a few lines above this
> > > addition.
> >
> > Oh. That would have made a heck of a convincing argument in the commit
> > message. Pity it was not mentioned. (Yes, please read that as a strong
> > suggestion to fix that in the next patch iteration.)
> 
> Done.

Good.

> > FWIW I dug out the original submission:
> > http://thread.gmane.org/gmane.comp.version-control.git/151297/focus=151435
> >
> > It seems that there was no discussion about the commit-msg. Which
> > makes me wonder why nobody thought of this.
> >
> > Now, you could make a case that you want to run the commit-msg hook in
> > the same spirit as prepare-commit-msg (and mention that apparently
> > nobody thought of that when the patch was accepted into
> > builtin/merge.c).
> >
> > But then I wonder what your argument would be for *not* running the
> > pre-commit and the post-commit hooks in `git merge` as well?
> >
> > Seems like a big inconsistency to me, one that would not be helped by
> > a piecemeal patch that does only half the job of resolving the
> > inconsistency.
> >
> > There was actually a question why the post-commit hook was not run in
> > `git merge`:
> > http://thread.gmane.org/gmane.comp.version-control.git/168716/focus=168773
> > (but it seems nobody cared all that much).
> >
> 
> pre-commit seems to have been rejected, though I must admit I don't
> fully understand why.  post-commit might make sense, but I wouldn't
> include it in the same patch.  These are different issues.

I did not mean to include that change in the patch. I meant to make a case
for, or against, it, in the commit message.

The commit message is an excellent place to demonstrate the usefulness of
the change as well as background information that lets the reader
understand how thorough the patch is. A commit message can increase the
trust in the rigidity of the patch.

That is why I suggested to research further by providing two links with
further information.

Now that I know that pre-commit has been rejected, of course, I want to
know why. Because the same argument might well preclude commit-msg support
from being added to `git merge` (and it might well lead to the
prepare-commit-msg hook to be deprecated in `git merge`).

This is all very useful information. We are slowly getting to the full
picture needed to assess whether to include this patch or not.

> > > > - a merge is a different beast from a simple commit. That is why
> > > > we have two different commands for them. A hook to edit the merge
> > > > message may need to know the *second* parent commit, too, for
> > > > example to generate a diffstat, or to add information about
> > > > changes in an "evil commit".
> > >
> > > That is correct for a post-merge hook. Why should *message
> > > validation* differ between simple and merge commit?
> >
> > You yourself do not use the hook for validation. You use it to *edit*
> > the message. My examples do the very same thing. Why should they wait
> > for a *post-merge* hook to amend the message?
> >
> 
> Because commit-msg doesn't know anything about the commit.

That is incorrect. When that hook is called, `git rev-parse HEAD` refers
to the parent commit, and `GIT_INDEX_FILE` refers to the index that will be
written as a tree object. That is pretty much all the information needed
to know about the future commit.

> > Otherwise, why wouldn't you use the post-merge hook to add the Change-Id:
> > in your use case, too...
> >
> > > > - if Gerrit is the intended user, would it not make more sense to
> > > > introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`),
> > > > as you have to teach Gerrit a new trick anyway?
> > >
> > > Why is that new? Every commit in gerrit has a Change-Id footer, which is
> > > generated by commit-msg hook.
> >
> > So it already works for Gerrit? Why is this patch needed, then? This is
> > confusing.
> >
> 
> Gerrit is a server, the user installs a commit-msg hook provided by
> Gerrit on the local machine.  This hook currently works only for simple
> commits and not for (trivial) merge commits.  That's where this patch
> comes to the rescue.

Sorry, you really need to explain this better in the commit message.
Gerrit exists for quite some time, so I would assume that other developers
would have had serious problems in similar situations. How do they address
those challenges?

> > > What I currently do for merges that succeed without conflicts is
> > > unconditional commit --amend --no-edit just to run the hook.
> >
> > So you do that manually? Or you taught Gerrit to do that? Please
> > clarify.
> 
> Gerrit can't do anything on my machine. It's a web/ssh server. I have my
> own post-merge hook that runs commit --amend

Okay, so why exactly do you need the commit-msg?

All the concerns I raised, all the confusion *need* to be addressed by a
commit message that makes a good case for the change. That is what commit
messages are for. So far, the commit message of this patch is not up to
the task.

Ciao,
Johannes

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

end of thread, other threads:[~2016-07-27 12:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-26  7:48 [PATCH] merge: Run commit-msg hook Orgad Shaneh
2016-07-26 13:02 ` Johannes Schindelin
2016-07-26 13:50   ` Orgad Shaneh
2016-07-26 14:54     ` Johannes Schindelin
2016-07-26 21:12       ` Junio C Hamano
     [not found]       ` <CAGHpTBLN1vBv12fSBXK0taGzxynMymBWRu8FcG=miBy=raReHw@mail.gmail.com>
2016-07-27 12:35         ` Johannes Schindelin
2016-07-26 21:05     ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2016-07-26 15:32 Orgad Shaneh

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).