Barret Rennie <bar...@brennie.ca> writes:

>> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to