git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Barret Rennie <barret@brennie.ca>
Cc: "Johannes Sixt" <j6t@kdbg.org>,
	git@vger.kernel.org, "Eric Sunshine" <sunshine@sunshineco.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Michael Rappazzo" <rappazzo@gmail.com>
Subject: Re: [PATCH] builtin/worktree.c: add option for setting worktree name
Date: Sat, 25 Jun 2016 12:45:10 -0700	[thread overview]
Message-ID: <xmqq1t3ldpdl.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1FEF5F90-6534-4D91-B27C-16FE6D16EC3F@brennie.ca> (Barret Rennie's message of "Sat, 25 Jun 2016 01:29:49 -0600")

Barret Rennie <barret@brennie.ca> writes:

>> What is "the name for the worktree"? Is it the directory where it lives in?
>>Is it how it is listed with 'git worktree list'?
>
> The name of the worktree is the name of the created directory in
> `.git/worktrees`.
>
>> How is --name different from the <path> argument?
>
> Currently, if you run:
> 	
> 	git worktree add /my/worktree/checkout <branch>
>
> you get a worktree "named" checkout, i.e., `.git/worktrees/checkout`. The
> idea with this patch is to allow you use a more specific name when you would
> otherwise have mulitiple worktrees of the form `checkout`, `checkout1`, etc.
>
> That is, you could do
>
> 	git worktree add --name branch1 /worktrees/branch1/src branch1
> 	git worktree add --name branch2 /worktrees/branch2/src branch2
> 	git worktree add --name branch3 /worktrees/branch3/src branch3
>
> and have `.git/worktrees/branch1`, `.git/worktrees/branch2` and
> `.git/worktrees/branch3` instead of `.git/worktrees/src`,
> `.git/worktrees/src1`, `.git/worktrees/src2`. That way, it becomes more clear
> when poking inside `.git/worktrees` which directory points to which checkout.

That is a way better justification of "why we need to use a custom
name, not the default one" than the previous "with this we can use a
custom name".

As long as you can justify why having anything underneath branch$n/
is necessary, that is.  In your explanation above, it is still
unclear why you need a checkout at /worktrees/branch$n/src/, and why
it would not work if it is at /worktrees/branch$n/.

Note that I am not saying "there cannot be a good reason, do not add
this feature" when I say "it is unclear why".  I am encouraging you
and others in this discussion thread to find good use cases for the
proposed new feature and come up with materials to help improving
the documentation part of the patch.  That way, the users with
similar needs can find how the feature is supposed to be used and
understand the feature better.

I suspect that this new feature might be useful when two more more
interdependent projects (they could be organized as submodules in a
superproject, but they can be independent checkouts of different
projects) are used together.  Imagine frotz and nitfol projects, and
without fancier setup to have multiple checkouts, you may be
expected (by these two projects) to check them out like so:

    $top/frotz/
    $top/libs/nitfol/

where $top can be anywhere but to clarify the line of thought, lets
pick a concrete place, say $HOME/xyzzy.  So without worktrees, you
would have

    $HOME/xyzzy/frotz
    $HOME/xyzzy/libs/nitfol

Now, if you do the worktree, you may still want the relative
structure between these two, i.e. if you want to work on two
different branch combinations of the whole thing, you would want to
do this:

    $HOME/xyzzy-1/frotz       - borrow from $HOME/xyzzy/frotz
    $HOME/xyzzy-1/libs/nitfol - likewise for nitfol

    $HOME/xyzzy-2/frotz       - borrow from $HOME/xyzzy/frotz
    $HOME/xyzzy-2/libs/nitfol - likewise for nitfol

where xyzzy-$n may be for topic-$n branch both in frotz and nitfol.

And explained that way, it becomes clearer that you would want to
name $HOME/xyzzy-1/frotz worktree after "topic-1", not the default
name you would get "frotz" (because the default gives you the leaf
level name of the newly created worktree).

After the discussion above (which may or may not match what you
raised this topic for), I think a feature to let you override the
default name makes sense.

It just needs to be explained better to help the users when the
feature eventually becomes part of Git.  Also, others (especially
Duy) may have even better ideas (e.g. instead of having to always
use --name to give custom name for all worktrees, set a "hint" just
once to help the logic that comes up with the default name give a
better name), so while the feature may be desirable, your exact
implementation may or may not be what we eventually want to adopt.

Thanks.



  reply	other threads:[~2016-06-25 19:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-25  5:15 [PATCH] builtin/worktree.c: add option for setting worktree name Barret Rennie
2016-06-25  6:17 ` Junio C Hamano
2016-06-25  6:28   ` Barret Rennie
2016-06-25  7:15 ` Johannes Sixt
2016-06-25  7:29   ` Barret Rennie
2016-06-25 19:45     ` Junio C Hamano [this message]
2016-06-25 20:19       ` Barret Rennie
2016-06-26 18:15       ` Junio C Hamano
2016-06-27  5:40         ` Barret Rennie
2016-06-27 13:17           ` Junio C Hamano
2016-06-26 23:00       ` Eric Sunshine
2016-06-27  5:52         ` Barret Rennie
2016-06-27 23:11           ` Eric Sunshine
2016-06-29  4:45             ` Barret Rennie
2016-06-25  7:29   ` Barret Rennie
2016-06-25  7:32   ` Barret Rennie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1t3ldpdl.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=barret@brennie.ca \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=pclouds@gmail.com \
    --cc=rappazzo@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).