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