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

Re: [PATCH] builtin/worktree.c: add option for setting worktree name

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 27, 2016, 13:17 UTC
Message-ID
<xmqqk2hadb3z.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<036C19B4-5941-43E4-AE2A-8782797D9523@brennie.ca>
Barret Rennie <barret@brennie.ca> writes:
Show 28 quoted lines
>> For example, the "frotz" and "nitfol" repositories (i.e. where their
>> worktrees borrow their refs and object stores from) could have a
>> single configuration variable each, i.e.
>> 
>> 	(in $HOME/xyzzy/frotz/.git/config)
>>        [worktree] location = "~/*/frotz"
>> 
>> 	(in $HOME/xyzzy/libs/nitfol/.git/config)
>>        [worktree] location = "~/*/libs/nitfol"
>> 
>> and then the user could do in each of these two repositories
>> 
>> 	$ git -C ~/xyzzy/frotz worktree add --by-name xyzzy-1 topic-1
>> 	$ git -C ~/xyzzy/lib/nitfol worktree add --by-name xyzzy-1 topic-1
>> 
>> to get the desired layout instead.
>> 
>> The traditional way may be "create one HERE", and your patch tries
>> to tweak it to "create one at HERE with this NAME".  The above
>> attempts to remove the need for specifying the exact location every
>> time a new worktree is created, and instead let you specify the
>> systematic way in which you lay out your worktrees based on their
>> names.
>
> Are you proposing that `--by-name` creates a worktree in the current working
> directory or that the default behaviour of `git worktree add` is changed to
> to create the worktree in the current working directory when executed with
> only one argument (the branch)?
It is not a proposal but an illustration of what I meant by "hint".

What I am envisioning is that we may enhance the "worktree add" subcommand to take two forms. In addition to traditional

    $ git worktree add [opts] <path> [<branch>]
when worktree.location configuration is present, you could say
    $ git worktree add [opts] --by-name <name> [<branch>]

omitting <path> and instead giving <name>. Use the <name> to substitute the wildcard in the pattern given by worktree.location, i.e. with the above example for "frotz",

    $ git worktree add --by-name xyzzy-1 topic-1

because the worktree.location configuration is set to "~/*/frotz", that would act as if <path> was given as ~/xyzzy-1/frotz. Name is set to xyzzy-1, and the newly created worktree would initially check out topic-1 branch.

Previous: Barret RennieNext: Eric Sunshine
Message 11 of 16 in “builtin/worktree.c: add option for setting worktree name”
  1. builtin/worktree.c: add option for setting worktree nameBarret Rennie, Jun 25, 2016
  2. Junio C HamanoJun 25, 2016
  3. Barret RennieJun 25, 2016
  4. Johannes SixtJun 25, 2016
  5. Barret RennieJun 25, 2016
  6. Barret RennieJun 25, 2016
  7. Junio C HamanoJun 25, 2016
  8. Barret RennieJun 25, 2016
  9. Junio C HamanoJun 26, 2016
  10. Barret RennieJun 27, 2016
  11. Junio C HamanoJun 27, 2016
  12. Eric SunshineJun 26, 2016
  13. Barret RennieJun 27, 2016
  14. Eric SunshineJun 27, 2016
  15. Barret RennieJun 29, 2016
  16. Barret RennieJun 25, 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.