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

Re: 'git worktree add' does not fire post-checkout hook

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 7, 2017, 10:19 UTC
Message-ID
<CAPig+cRAth85f+Euim8Sw7An8UQQeOAo6e6kVP_yruw400aJug@mail.gmail.com>
In-Reply-To
<CAPig+cQXeC5Nh+=rO9U46PNgnNALd4H3on+feo_NzMg45HqUkQ@mail.gmail.com>
On Wed, Dec 6, 2017 at 4:45 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 17 quoted lines
> On Wed, Dec 6, 2017 at 4:00 PM, Gumbel, Matthew K
> <matthew.k.gumbel@intel.com> wrote:
>> I've noticed that when I run 'git worktree add /path/to/new/tree',
>> the post-checkout hook does not fire, even though the worktree
>> manpage explicitly states that "worktree add" will, "Create <path>
>> and checkout <branch> into it."
>>
>> Is this the intended behavior? Seems like maybe a bug, but I'm not
>> sure.
>
> If you'd like to get your feet wet at contributing to the Git project,
> this might be a good first dip, as it looks like an easy fix (a one-
> or two-liner). The only thing which needs a bit of care is to skip the
> hook when --no-checkout is specified. Other than that, 'githooks'
> documentation would need an update to mention that git-worktree also
> runs the hook, and t2025-worktree-add.sh would want a couple new tests
> (which would probably be the most complex part of the patch).

I worked up a patch to fix this oversight which I'll try to send out later today.

Previous: Eric Sunshine
Message 3 of 3 in “'git worktree add' does not fire post-checkout hook”
  1. Gumbel, Matthew KDec 6, 2017
  2. Eric SunshineDec 6, 2017
  3. Eric SunshineDec 7, 2017

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.