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

Re: [PATCH] worktree: add shorthand '-d' for detach

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 27, 2020, 16:28 UTC
Message-ID
<CAPig+cRrVQNtXGCjWcj5eDbPCQyO-NfjqKAVh8tD3sLc=KdjjQ@mail.gmail.com>
In-Reply-To
<20200125173744.4334-1-me@yadavpratyush.com>
On Sat, Jan 25, 2020 at 12:37 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
Show 12 quoted lines
> [...]
> An alternative to this is to create a detached worktree which doesn't
> lead to a branch being created. This can be done by the '--detach'
> option. Add the shorthand to make it more convenient to use it.
>
> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
> ---
> For more context:
> https://lore.kernel.org/git/CAPig+cQmqKiYWDWFH5eK2S6XPOi2t2+8Oas8yZa8R=bKLym3wQ@mail.gmail.com/
>
> I'll send a patch to add the config option as a follow up some time
> later.

Although the suggestion of a config option came from me (in [1] and extended in [2]), I had second thoughts about it very shortly after sending [2], and can't say that I am particularly in favor of it. There are at least a couple reasons why I have taken this view.

First, the idea suggested in [2] can be seen as a specialized mechanism which is perhaps already handled better by the more generalized mechanism provided by Git aliases. That is, someone can achieve the same goal of conveniently providing a particular set of command-line options by simply defining a Git alias; for instance, "git wttemp" might expand to "git worktree add --detach". We don't need to be re-inventing the wheel (poorly).

Second, the only real case which has arisen thus far is that of throwaway (detached) worktrees, and the added '-d' alias for '--detach' makes that about as simple as possible to achieve without requiring any extra machinery. If, at some point down the road, other real-world cases arise in which it would be convenient to tweak worktree creation in some mechanized fashion, perhaps then it would make sense to implement all the extra code to support such a config option, but right now it seems overkill.

[1]: https://lore.kernel.org/git/CAPig+cQmqKiYWDWFH5eK2S6XPOi2t2+8Oas8yZa8R=bKLym3wQ@mail.gmail.com/ [2]: https://lore.kernel.org/git/CAPig+cTva89t8Zco-Ke0oD5xDZF_uuGH-gSkLXE2r31NtSE8nw@mail.gmail.com/

Previous: Junio C Hamano
Message 5 of 5 in “worktree: add shorthand '-d' for detach”
  1. worktree: add shorthand '-d' for detachPratyush Yadav, Jan 25, 2020
  2. SZEDER GáborJan 27, 2020
  3. Eric SunshineJan 27, 2020
  4. Junio C HamanoJan 27, 2020
  5. Eric SunshineJan 27, 2020

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.