From: Junio C Hamano Date: Mon, 27 Jun 2016 13:17:52 GMT Subject: Re: [PATCH] builtin/worktree.c: add option for setting worktree name Message-ID: In-Reply-To: <036C19B4-5941-43E4-AE2A-8782797D9523@brennie.ca> Barret Rennie 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] [] when worktree.location configuration is present, you could say $ git worktree add [opts] --by-name [] omitting and instead giving . Use the 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 was given as ~/xyzzy-1/frotz. Name is set to xyzzy-1, and the newly created worktree would initially check out topic-1 branch.