git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Pass amend to pre-commit hook

From
Øystein Walle <oystwa@gmail.com>
Date
Sep 27, 2015, 22:09 UTC
Message-ID
<loom.20150928T000850-141@post.gmane.org>
In-Reply-To
<20150914144727.GA25003@sigill.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 22 quoted lines
> 
> On Mon, Sep 14, 2015 at 01:14:20PM +0100, Alan Clucas wrote:
> 
> > Pass a single parameter 'amend' to the pre-commit hook when performing a
> > commit amend.
> 
> I think this is a sensible thing to want, and it has come up a few
> times. I'm not sure why the last round didn't get merged, though. Looks
> like it just slipped through the cracks.
> 
> Here are the relevant threads:
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/260122
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/260245
> 
> Looks like there was some question of what to pass in the normal,
> non-amend case. I've added interested parties from the original thread
> to the cc here.
> 
> -Peff
> 

There were so many different ways of solving them that we weren't able to decide between them:

Assuming we give the string "amend" as the hook's argv[1], what to do when --amend is not used? We can pass nothing, or the empty string, or the string "noamend". Then there was the suggestion of exporting GIT_AMEND=1 or something like that. In any case, what to do when we want to pass more arguments? Should we let the hook check argv[1] to decide whether --amend was used, argv[2] to check whether {some scenario here} is the case? Or make the hook author effectively implement options parsing?

And then it died out...

In my totally unprofessional opinion anything more complex than maybe passing "amend" in argv[1] is unwarranted. Since I posted my first patch almost a year ago there has been no discussion regarding passing other information along to pre-commit. Furthermore --amend is the only thing I know of that a pre-commit hook cannot discover on its own. On the other hand the desire for this has popped up at least twice on #git in the same time span.

Alan Clucas' solution looks fine to me. It is essentially the same as mine. But mine had tests and whatnot ;-)

Øsse
Previous: Alan Clucas
Message 4 of 4 in “Pass amend to pre-commit hook”
  1. Pass amend to pre-commit hookAlan Clucas, Sep 14, 2015
  2. Jeff KingSep 14, 2015
  3. Alan ClucasSep 14, 2015
  4. Øystein WalleSep 27, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.