On Fri, Feb 01, 2019 at 02:06:43PM +0700, Duy Nguyen wrote:
> worrying about races like this. The mkdir loop would be one way to go.
> But I'm going to add a new option to let the user control this
> directory name. This is necessary since this name is now exposed via
> "worktrees/<name>" reference space and should also be reported in "git
> worktree list". Avoiding the race is a nice bonus.
I'm not going to bother you with code yet (although if you want, you
can check out branch worktree-name on my gitlab repo), but this is
what the user facing changes look like. Looking good?
PS. I think this also calls for a command to rename working trees.
Sigh.. this worktree thingy never ends.
-- 8< --
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 18469e202e..d5db69dec7 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -9,7 +9,7 @@ git-worktree - Manage multiple working trees
SYNOPSIS
--------
[verse]
-'git worktree add' [-f] [--detach] [--checkout] [--lock] [-b <new-branch>]
<path> [<commit-ish>]
+'git worktree add' [-f] [--detach] [--checkout] [--lock] [-b <new-branch>]
[--name <name>] <path> [<commit-ish>]
'git worktree list' [--porcelain]
'git worktree lock' [--reason <string>] <worktree>
'git worktree move' <worktree> <new-path>
@@ -195,6 +195,13 @@ This can also be set up as the default behaviour by using
the
--reason <string>::
With `lock`, an explanation why the working tree is locked.
+--name <name>::
+ Name of the working tree. Each working tree must have a unique
+ name. This is also the directory name containing all working
+ tree's specific information under `$GIT_COMMON_DIR/worktrees`.
+ If `--name` is not given, the name is based on basename(3)
+ optionally with a number suffix to make it unique.
+
<worktree>::
Working trees can be identified by path, either relative or
absolute.
@@ -323,11 +330,15 @@ details on a single line with columns. For example:
------------
$ git worktree list
-/path/to/bare-source (bare)
-/path/to/linked-worktree abcd1234 [master]
-/path/to/other-linked-worktree 1234abc (detached HEAD)
+(main) /path/to/bare-source (bare)
+linked /path/to/linked-worktree abcd1234 [master]
+other /path/to/other-linked-worktree 1234abc (detached HEAD)
------------
+The first column is the name of the working tree. The second column is
+the location of the working tree. The third column is the short commit
+name of the current branch. The branch name is put in square brackets.
+
Porcelain Format
~~~~~~~~~~~~~~~~
The porcelain format has a line per attribute. Attributes are listed with a
@@ -341,10 +352,12 @@ $ git worktree list --porcelain
worktree /path/to/bare-source
bare
+name linked
worktree /path/to/linked-worktree
HEAD abcd1234abcd1234abcd1234abcd1234abcd1234
branch refs/heads/master
+name other
worktree /path/to/other-linked-worktree
HEAD 1234abc1234abc1234abc1234abc1234abc1234a
detached
-- 8< --
--
Duy