Re: [PATCH v7 0/4] worktree: teach "add" to check out existing branches

2018-04-22 Thread Eric Sunshine
On Sun, Apr 15, 2018 at 4:29 PM, Thomas Gummerer  wrote:
> The main change once again in this series is the user interface.  It
> feels like we went in a complete circle here now, as this iteration is
> bringing the "Preparing ..." line back (although in a slightly
> different form than the original), and is moving away from printing
> it's own "HEAD is now at..." line again.  This also means we don't
> need the new hidden option to 'git reset' anymore, which is nice.

I'm glad to see the proposed hidden git-reset option go away, and am
likewise happy to see that worktree no longer wants to print "HEAD is
now at" itself. I'm much more pleased with the direction this series
is now taking than in earlier rounds. It's also much simpler, which is
a nice plus.

> I do like the new UI more than what we had in the last round (which I
> already liked more than the original UI) :)
>
> To demonstrate the UI updates, let's compare the new UI and the old UI
> again.  This is the same commands as used for the demonstration in the
> last iteration, so please have a look at 
> <20180331151804.30380-1-t.gumme...@gmail.com>
> for an example of what it looked like after the last round.

Thanks for presenting examples of the new UI under various conditions.
Like you, I find the new "Preparing..." message superior to and much
more useful than the original.

Aside from the problem pointed out in my review of 2/4 in which it
incorrectly shows "detached HEAD" for "git worktree add wt
existing-local-branch", I think this series is just about ready, and
hope to see it land with the next re-roll.

Thanks for working on it.


[PATCH v7 0/4] worktree: teach "add" to check out existing branches

2018-04-15 Thread Thomas Gummerer
Thanks Eric for the review and all of the suggestions in the last
round.

Previous rounds are at <20180121120208.12760-1-t.gumme...@gmail.com>,
<20180204221305.28300-1-t.gumme...@gmail.com>,
<20180317220830.30963-1-t.gumme...@gmail.com>,
<2018031719.4940-1-t.gumme...@gmail.com>,
<20180325134947.25828-1-t.gumme...@gmail.com> and
<20180331151804.30380-1-t.gumme...@gmail.com>.

The main change once again in this series is the user interface.  It
feels like we went in a complete circle here now, as this iteration is
bringing the "Preparing ..." line back (although in a slightly
different form than the original), and is moving away from printing
it's own "HEAD is now at..." line again.  This also means we don't
need the new hidden option to 'git reset' anymore, which is nice.

I do like the new UI more than what we had in the last round (which I
already liked more than the original UI) :)

Other than those changes, it also includes Eric's suggestion for a
better wording in the documentation, fixes the argument order to
test_cmd_rev in a test, and makes a test more robust.

To demonstrate the UI updates, let's compare the new UI and the old UI
again.  This is the same commands as used for the demonstration in the
last iteration, so please have a look at 
<20180331151804.30380-1-t.gumme...@gmail.com> 
for an example of what it looked like after the last round.

New UI:

 - guess-remote mode

$ git worktree add --guess-remote ../next
Preparing worktree (new branch 'next')
Branch 'next' set up to track remote branch 'next' from 'origin'.
HEAD is now at caa68db14 Merge branch 'sb/packfiles-in-repository' into next

 - original dwim (create a branch based on the current HEAD)

$ git worktree add ../test
Preparing worktree (new branch 'test')
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

 - new dwim (check out existing branch)

$ git worktree add ../test
Preparing worktree (checking out 'test')
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

 - detached HEAD

$ git worktree add ../test2 origin/master
Preparing worktree (detached HEAD c2a499e6c)
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

 - resetting existing branch

$ git worktree add -B next ../test3 origin/master
Preparing worktree (resetting branch 'next' (was at caa68db14))
Branch 'next' set up to track remote branch 'master' from 'origin'.
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

This output is new in this round and wasn't previously discussed.
While working on the "Preparing ..." line I noticed this, and
thought it would be a good idea.  I feel like this fits in the
scope of the series quite well, as it's improving the UI, but I'm
happy to split it out if that's preferred.

It may also be worth displaying the title of the commit here, but
at that point the line would get a bit long, so dunno.

 - large repository (with original dwim)

$ git worktree add ../test
Preparing worktree (new branch 'test')
Checking out files: 100% (62915/62915), done.
HEAD is now at c2a9838452a4 Merge tag 'for-4.16/dm-fixes-4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

 - error when directory already exists

$ git worktree add ../test
Preparing worktree (checking out 'test')
fatal: '../test' already exists

Compare this to the old UI (new dwim omitted, as there's no old
version of that):

 - guess-remote mode

$ git worktree add --guess-remote ../next
Branch 'next' set up to track remote branch 'next' from 'origin'.
Preparing ../next (identifier next)
HEAD is now at caa68db14 Merge branch 'sb/packfiles-in-repository' into next

 - original dwim (create a branch based on the current HEAD)

$ git worktree add ../test
Preparing ../test (identifier test)
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

 - no new branch created

$ git worktree add ../test2 origin/master
Preparing ../test2 (identifier test2)
HEAD is now at c2a499e6c Merge branch 'jh/partial-clone'

 - large repository

$ git worktree add ../test
Preparing ../test (identifier test)
Checking out files: 100% (62915/62915), done.
HEAD is now at c2a9838452a4 Merge tag 'for-4.16/dm-fixes-4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

 - error when directory already exists

$ git worktree add ../test
fatal: '../test' already exists

Interdiff below:

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index eaa6bf713f..5d54f36a71 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -61,13 +61,13 @@ $ git worktree add --track -b   
/
 
 +
 If `` is omitted and neither `-b` nor `-B` nor `--detach` used,
-then, as a convenience, a worktree with a branch named after
-`$(basename )` (call it ``) is created.  If ``
+then, as a convenience, the new worktree is a