{"thread":{"id":"9712","subject":"[PATCH] Add post-merge hook.","startedAt":"2007-08-30T22:40:17Z","lastAt":"2007-09-04T21:23:49Z","messageCount":9,"participants":["jjengla@sandia.gov","Junio C Hamano","Josh England","Steven Grimm"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"51956","messageId":"11885136172952-git-send-email-jjengla@sandia.gov","threadId":"9712","inReplyTo":null,"subject":"[PATCH] Add post-merge hook.","fromName":"","fromEmail":"jjengla@sandia.gov","sentAt":"2007-08-30T22:40:17Z","receivedAt":"2007-08-30T22:40:17Z","isPatch":true,"sender":{"key":"jjengla@sandia.gov","avatar":null},"body":"From: Josh England <jjengla@sandia.gov>\n\nThis adds a post-merge hook that will run after `git pull` operations\nif enabled.  The hook is passed no arguments and cannot affect the\noutcome of a merge.\n\nSigned-off-by: Josh England <jjengla@sandia.gov>\n---\n Documentation/hooks.txt |    8 ++++++++\n git-merge.sh            |    6 ++++++\n 2 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/hooks.txt b/Documentation/hooks.txt\nindex c39edc5..841b37f 100644\n--- a/Documentation/hooks.txt\n+++ b/Documentation/hooks.txt\n@@ -87,6 +87,14 @@ parameter, and is invoked after a commit is made.\n This hook is meant primarily for notification, and cannot affect\n the outcome of `git-commit`.\n \n+post-merge\n+-----------\n+\n+This hook is invoked by `git-merge`, which happens when a `git pull`\n+is done on a local repository.\n+\n+The hook takes no parameters, and cannot affect the outcome of `git-merge`.\n+\n [[pre-receive]]\n pre-receive\n -----------\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 3a01db0..0a77bfb 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -97,6 +97,12 @@ finish () {\n \t\tfi\n \t\t;;\n \tesac\n+\n+\t# Run a post-merge hook\n+        if test -x \"$GIT_DIR\"/hooks/post-merge\n+        then\n+                \"$GIT_DIR\"/hooks/post-merge\n+        fi\n }\n \n merge_name () {\n-- \n1.5.3.rc7-dirty\n"},{"id":"51959","messageId":"7v7inc7hao.fsf@gitster.siamese.dyndns.org","threadId":"9712","inReplyTo":"11885136172952-git-send-email-jjengla@sandia.gov","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-30T23:07:27Z","receivedAt":"2007-08-30T23:07:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"jjengla@sandia.gov writes:\n\n> From: Josh England <jjengla@sandia.gov>\n>\n> This adds a post-merge hook that will run after `git pull` operations\n> if enabled.  The hook is passed no arguments and cannot affect the\n> outcome of a merge.\n>\n> Signed-off-by: Josh England <jjengla@sandia.gov>\n\nThanks for your patch.\n\nTwo questions.\n\n * Do you want to run the post-merge hook even for a squash\n   merge?\n\n * After resolving a conflicted merge, you would conclude it\n   with \"git commit\"; don't you want to have the same hook apply\n   at the commit time, or is that what you expect the user to\n   deal with with post-commit hook?\n\n\nAnd two requests and a half.\n\n - We would want a new test in the test suite for this, to make\n   sure that later changes by others would not break this new\n   feature you would depend upon.\n\n - You described _what_ the patch and the new feature do in the\n   log message and in the documentation.\n\n   You need to also explain _why_ somebody might want to have\n   such a hook in his repository.\n\n   . In the documentation, you would want to make the reader\n     realize \"aha, this is something that would help me\" with an\n     example.\n\n   . In the log message, you would want to make sure other\n     people understand why this new feature was added, what the\n     design consideration were at the point of the feature was\n     added.\n\n   The latter is important to me personally.  I want to have\n   something better than \"this change does not break anything\n   existing, and it is something somebody wants to get added, so\n   while I can not image the exact use scenario why anybody\n   would want to use such a hook I'd apply the change\" to\n   convince myself.\n\n - We are deep in feature-freeze for 1.5.3; I'd appreciate a\n   resend for any patch that is not a bugfix / documentation\n   update after 1.5.3 final.\n"},{"id":"52480","messageId":"1188923110.6192.15.camel@beauty","threadId":"9712","inReplyTo":"7v7inc7hao.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Josh England","fromEmail":"jjengla@sandia.gov","sentAt":"2007-09-04T16:25:10Z","receivedAt":"2007-09-04T16:25:10Z","isPatch":true,"sender":{"key":"jjengla@sandia.gov","avatar":null},"body":"Sorry for late response --- *long* weekend.  :)\n\nOn Thu, 2007-08-30 at 16:07 -0700, Junio C Hamano wrote:\n> > This adds a post-merge hook that will run after `git pull` operations\n> > if enabled.  The hook is passed no arguments and cannot affect the\n> > outcome of a merge.\n> >\n> > Signed-off-by: Josh England <jjengla@sandia.gov>\n> \n> Thanks for your patch.\n> \n> Two questions.\n> \n>  * Do you want to run the post-merge hook even for a squash\n>    merge?\n\nYes.  I'd like to run it at any time that the working tree might be\nupdated.\n\n>  * After resolving a conflicted merge, you would conclude it\n>    with \"git commit\"; don't you want to have the same hook apply\n>    at the commit time, or is that what you expect the user to\n>    deal with with post-commit hook?\n\nI wouldn't want the post-merge hook running there because (in my case)\nit needs to do something slightly different than the post-commit hook,\nand would seem counter-intuitive to me. The pre-commit and post-commit\nhooks are already there and handle that scenario nicely.\n\n> And two requests and a half.\n> \n>  - We would want a new test in the test suite for this, to make\n>    sure that later changes by others would not break this new\n>    feature you would depend upon.\n\nCan do.  You want me to resubmit the original patch along with tests or\nsubmit the tests as a new patch?\n\n>  - You described _what_ the patch and the new feature do in the\n>    log message and in the documentation.\n> \n>    You need to also explain _why_ somebody might want to have\n>    such a hook in his repository.\n> \n>    . In the documentation, you would want to make the reader\n>      realize \"aha, this is something that would help me\" with an\n>      example.\n> \n>    . In the log message, you would want to make sure other\n>      people understand why this new feature was added, what the\n>      design consideration were at the point of the feature was\n>      added.\n\nI may have to come up with a use-case that is more mainstream than mine.\nI'm personally using it to update permissions/ownership in the working\ntree based on a git-controlled file (created by pre-commit).  I'll post\nthe script when its fully fleshed out.  Should I just put \"If you're\ndoing something crazy like me, this hook may be useful.\"  :)\n\n>  - We are deep in feature-freeze for 1.5.3; I'd appreciate a\n>    resend for any patch that is not a bugfix / documentation\n>    update after 1.5.3 final.\n\nSure thing.  It looks like the 1.5.4 cycled just started.  I'll resend\nwith the additions you requested.\n\n-JE\n"},{"id":"52493","messageId":"7vmyw2ny05.fsf@gitster.siamese.dyndns.org","threadId":"9712","inReplyTo":"1188923110.6192.15.camel@beauty","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-04T17:25:46Z","receivedAt":"2007-09-04T17:25:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Josh England\" <jjengla@sandia.gov> writes:\n\n>> Two questions.\n>> \n>>  * Do you want to run the post-merge hook even for a squash\n>>    merge?\n>\n> Yes.  I'd like to run it at any time that the working tree might be\n> updated.\n\nIf that is the case, perhaps your hook may want to get a\nparameter to tell it what kind of \"git-merge\" invocation it was?\nSquash merge does not even advance the HEAD and is of a very\ndifferent nature from a normal merge.\n\n>>  - We would want a new test in the test suite for this, to make\n>>    sure that later changes by others would not break this new\n>>    feature you would depend upon.\n>\n> Can do.  You want me to resubmit the original patch along with tests or\n> submit the tests as a new patch?\n\nI'd like a full resend whenever I reject a patch with a\ncomment.  That way the patch will be easier to review with\ncontext by other people.\n\nThanks.\n"},{"id":"52506","messageId":"1188934573.6192.35.camel@beauty","threadId":"9712","inReplyTo":"7vmyw2ny05.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Josh England","fromEmail":"jjengla@sandia.gov","sentAt":"2007-09-04T19:36:13Z","receivedAt":"2007-09-04T19:36:13Z","isPatch":true,"sender":{"key":"jjengla@sandia.gov","avatar":null},"body":"On Tue, 2007-09-04 at 10:25 -0700, Junio C Hamano wrote:\n> \"Josh England\" <jjengla@sandia.gov> writes:\n> \n> >> Two questions.\n> >> \n> >>  * Do you want to run the post-merge hook even for a squash\n> >>    merge?\n> >\n> > Yes.  I'd like to run it at any time that the working tree might be\n> > updated.\n> \n> If that is the case, perhaps your hook may want to get a\n> parameter to tell it what kind of \"git-merge\" invocation it was?\n> Squash merge does not even advance the HEAD and is of a very\n> different nature from a normal merge.\n\nOK.  Should it just pass in a flag (squash or normal), or are there\nother merge types it should need to know about.\n\n-JE\n"},{"id":"52509","messageId":"7vodgimc53.fsf@gitster.siamese.dyndns.org","threadId":"9712","inReplyTo":"1188934573.6192.35.camel@beauty","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-04T20:03:20Z","receivedAt":"2007-09-04T20:03:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Josh England\" <jjengla@sandia.gov> writes:\n\n> On Tue, 2007-09-04 at 10:25 -0700, Junio C Hamano wrote:\n>> \"Josh England\" <jjengla@sandia.gov> writes:\n>> \n>> >> Two questions.\n>> >> \n>> >>  * Do you want to run the post-merge hook even for a squash\n>> >>    merge?\n>> >\n>> > Yes.  I'd like to run it at any time that the working tree might be\n>> > updated.\n>> \n>> If that is the case, perhaps your hook may want to get a\n>> parameter to tell it what kind of \"git-merge\" invocation it was?\n>> Squash merge does not even advance the HEAD and is of a very\n>> different nature from a normal merge.\n>\n> OK.  Should it just pass in a flag (squash or normal), or are there\n> other merge types it should need to know about.\n\nI suspect you have thought abuot the issues involved longer than\nI have ;-), so you should take whatever I say with grain of\nsalt, but I think you would also want to know fast-forwards and\nup-to-dates if the hook wants to be generic, not \"for Josh's\nworkflow only\".\n"},{"id":"52512","messageId":"1188937975.6192.59.camel@beauty","threadId":"9712","inReplyTo":"7vodgimc53.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Josh England","fromEmail":"jjengla@sandia.gov","sentAt":"2007-09-04T20:32:55Z","receivedAt":"2007-09-04T20:32:55Z","isPatch":true,"sender":{"key":"jjengla@sandia.gov","avatar":null},"body":"On Tue, 2007-09-04 at 13:03 -0700, Junio C Hamano wrote:\n> >> >>  * Do you want to run the post-merge hook even for a squash\n> >> >>    merge?\n> >> >\n> >> > Yes.  I'd like to run it at any time that the working tree might be\n> >> > updated.\n> >> \n> >> If that is the case, perhaps your hook may want to get a\n> >> parameter to tell it what kind of \"git-merge\" invocation it was?\n> >> Squash merge does not even advance the HEAD and is of a very\n> >> different nature from a normal merge.\n> >\n> > OK.  Should it just pass in a flag (squash or normal), or are there\n> > other merge types it should need to know about.\n> \n> I suspect you have thought abuot the issues involved longer than\n> I have ;-), so you should take whatever I say with grain of\n> salt, but I think you would also want to know fast-forwards and\n> up-to-dates if the hook wants to be generic, not \"for Josh's\n> workflow only\".\n\nGeneric is great, I'm just trying to figure out when/why someone would\nneed to know the exact type of merge operation used.  The hook should be\ngeneric, yet not require an end user to know any git internals not\nexplicitly mentioned in the git-merge man page.  I'm thinking that it\nwill be sufficient to pass a flag indicating whether the working tree\nhas been modified or not.  The flag can be set for normal merge and\nfast-forward merges, and unset for up-to-dates and squash merges.  I\ndon't really know git internals myself.  Am I missing anything?\n\n-JE\n"},{"id":"52515","messageId":"46DDC576.3080708@midwinter.com","threadId":"9712","inReplyTo":"1188937975.6192.59.camel@beauty","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-09-04T20:52:06Z","receivedAt":"2007-09-04T20:52:06Z","isPatch":true,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Josh England wrote:\n> I'm thinking that it\n> will be sufficient to pass a flag indicating whether the working tree\n> has been modified or not.  The flag can be set for normal merge and\n> fast-forward merges, and unset for up-to-dates and squash merges.\n>   \n\nSquash merges modify the working tree. In fact, that's *all* they do -- \nthey don't commit anything.\n\n-Steve\n"},{"id":"52518","messageId":"1188941029.6192.73.camel@beauty","threadId":"9712","inReplyTo":"46DDC576.3080708@midwinter.com","subject":"Re: [PATCH] Add post-merge hook.","fromName":"Josh England","fromEmail":"jjengla@sandia.gov","sentAt":"2007-09-04T21:23:49Z","receivedAt":"2007-09-04T21:23:49Z","isPatch":true,"sender":{"key":"jjengla@sandia.gov","avatar":null},"body":"On Tue, 2007-09-04 at 13:52 -0700, Steven Grimm wrote:\n> Josh England wrote:\n> > I'm thinking that it\n> > will be sufficient to pass a flag indicating whether the working tree\n> > has been modified or not.  The flag can be set for normal merge and\n> > fast-forward merges, and unset for up-to-dates and squash merges.\n> >   \n> Squash merges modify the working tree. In fact, that's *all* they do -- \n> they don't commit anything.\n\nOK.  Looking at it closer, the post-merge hook should only run when\nthere has been a real merge (not run for up-to-dates), which seems\nalright with me.  With the immediate data at hand I could pass in a flag\nindicating a squash merge or not, or could simply pass in the current\nHEAD.  I think the first scenario is more appropriate.\n\n-JE\n"}]}