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

Re: Add post-worktree-add hook?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2016, 17:28 UTC
Message-ID
<xmqqy4bhv7za.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CACsJy8C9OELrkHZLzwoRx26AtzVvgouRA2+m0VH7GrJGSA8PCQ@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> I started moving my git work space to multi-worktree and found it
> annoying that every time I add a new worktree, my first step must be
> copy my config.mak over. Room for improvement. I see three options:
4) none of the above.

Everybody should learn to think before uttering post-X hook the following:

 * Is X an end user initiated action?
 * What does the hypothetical post-X hook need to decide what to do?
   If it needs to change behaviour based on what X did, does it need
   more than what it can get by observing its outcome (i.e. exit
   status and what is left in the working tree and the repository)?
 * Does the hypothetical post-X hook need other end-user supplied
   customization beyond what argument the end user gave to run X?

The answer to these questions would often reveal that post-X hook is a bad idea and you are much better off with a wrapper script that runs X as the first thing (and the remainder can do different things based on the outcome of X if you wanted it to).

Previous: Duy Nguyen
Message 2 of 2 in “Add post-worktree-add hook?”
  1. Duy NguyenJan 22, 2016
  2. Junio C HamanoJan 22, 2016

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.