git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Duy Nguyen <pclouds@gmail.com>,
	Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Thomas Gummerer <t.gummerer@gmail.com>
Subject: Re: [PATCH] checkout & worktree: introduce a core.DWIMRemote setting
Date: Fri, 4 May 2018 03:14:50 -0400	[thread overview]
Message-ID: <CAPig+cSRBBzXDWMJd5k=ZGOt_ayATWB6fZQrcMqJkP8ja4Tq+g@mail.gmail.com> (raw)
In-Reply-To: <87y3h1ykwn.fsf@evledraar.gmail.com>

On Wed, May 2, 2018 at 2:25 PM, Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> On Wed, May 02 2018, Eric Sunshine wrote:
>> A few observations:
>>
>> 1. DWIM has broad meaning; while this certainly falls within DWIM,
>> it's also just a _default_, so should this instead be named
>> "defaultRemote"?
>>
>> 2. Building on #1: How well is the term "DWIM" understood by non-power
>> users? A term, such as "default" is more well known.
>
> I've got no love for the DWIM term. And I think I should change it in
> v2, I just want some way to enable this functionality since this
> behavior has annoyed me for a long time.
>
> I wonder though if something like "core.defaultRemote" might not bring
> up connotations about whether this would e.g. affect "push" in the minds
> of users (not that my initial suggestion is better).

A reasonable concern.

> So maybe something like checkout.implicitRemote would be better? And we
> could just break the rule that only git-checkout would use it, since
> git-worktree could be said to be doing something checkout-like, or just
> also add a worktree.implicitRemote.

Considering that git-worktree runs the post-checkout hook, it seems
pretty safe to say that it does something checkout-like.

Personally, I find "defaultRemote" easier to understand than
"implicitRemote", but I suppose I can see your reasoning for choosing
"implicit". Whereas "default" is something to "fall back upon" when
something is missing, "implicit" suggests what to choose when a
something has not been specified explicitly.

>> 3. git-worktree learned --guess-remote and worktree.guessRemote in [1]
>> and [2], which, on the surface, sound confusingly similar to
>> "DWIMRemote". Even though I was well involved in the discussion and
>> repeatedly reviewed the patch series which introduced those, it still
>> took me an embarrassingly long time, and repeated re-reads of all
>> commit messages involved, to grasp (or re-grasp) how "guess remote"
>> and "DWIM remote" differ. If it was that difficult for me, as a person
>> involved in the patch series, to figure out "guess remote" vs. "DWIM
>> remote", then I worry that it may be too confusing in general. If the
>> new config option had been named "defaultRemote", I don't think I'd
>> have been confused at all.
>
> I hadn't looked at this at all before today when I wrote the patch, and
> I've never used git-worktree (but maybe I should...), but my
> understanding of this --[no-]guess-remote functionality is that it
> effectively splits up the functionality that the "git checkout" does,
> and we'll unconditionally check out the branch, but the option controls
> whether or not we'd set up the equivalent of remote tracking for
> git-worktree.
>
> But maybe I've completely misunderstood it.

Yes, you misunderstood it.

The setting up of a remote-tracking branch is DWIM'd as of 4e85333197
("worktree: make add <path> <branch> dwim", 2017-11-26); it doesn't
require an explicit option to enable it (though tracking can be
disabled via --no-track). The "guess-remote" feature does something
entirely different; it was added to avoid backward compatibility
problems.

In long-form:

    git worktree add <path> <branch>

adds a new worktree at <path> and checks out <branch>. As originally
implemented, shortened:

    git worktree add <path>

does one type of DWIM, as a convenience, and pretends that the user
actually typed:

    branch=$(basename <path>)
    git branch $branch HEAD
    git workree add <path> $branch

which creates a new branch and then checks it out in the new worktree
as usual. The "guess remote" feature which Thomas added augments that
by adding a DWIM which checks if $(basename <path>) names a
remote-tracking branch, in which case, it becomes shorthand for
(something like):

    branch=$(basename <path>)
    if remote-tracking branch named $branch exists:
        git branch --track $branch $guessedRemote/$branch
    else:
        git branch $branch HEAD
    fi
    git worktree add <path> $branch

In retrospect, this DWIM-checking for a like-named remote-tracking
branch should have been implemented from the start in git-worktree
since it mirrors how "git checkout <branch>" will DWIM remote-tracking
<remote>/<branch>. However, such DWIM'ing was overlooked and
git-worktree existed long enough without it that, due to backward
compatibility concerns, the new DWIM'ing got hidden behind a switch,
hence --guess-remote ("worktree.guessRemote") to enable it.

Unrelated: Thomas added another DWIM, which we just finalized a few
days ago, which extends the shorthand "git worktree add <path>" to
first check if a local branch named $(basename <path>) already exists
and merely check that out into the new worktree rather than trying to
create a new branch of that name (which is another obvious DWIM missed
during initial implementation). In other words:

    branch=$(basename <path>)
    if local branch named $branch does _not_ exist:
        if remote-tracking branch named $branch exists:
            git branch --track $branch $guessedRemote/$branch
        else:
            git branch $branch HEAD
        fi
    fi
    git worktree add <path> $branch

  parent reply	other threads:[~2018-05-04  7:14 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 10:54 [PATCH] checkout & worktree: introduce a core.DWIMRemote setting Ævar Arnfjörð Bjarmason
2018-05-02 15:21 ` Duy Nguyen
2018-05-02 18:00   ` Eric Sunshine
2018-05-02 18:09     ` Duy Nguyen
2018-05-02 18:25     ` Ævar Arnfjörð Bjarmason
2018-05-03 13:18       ` [PATCH v2] checkout & worktree: introduce checkout.implicitRemote Ævar Arnfjörð Bjarmason
2018-05-03 15:14         ` Duy Nguyen
2018-05-04  7:54           ` Ævar Arnfjörð Bjarmason
2018-05-04 14:58             ` Duy Nguyen
2018-05-04 18:02               ` Ævar Arnfjörð Bjarmason
2018-05-04  9:58         ` Eric Sunshine
2018-05-24 19:47           ` [PATCH v3] " Ævar Arnfjörð Bjarmason
2018-05-25  8:12             ` Junio C Hamano
2018-05-25 14:42               ` Duy Nguyen
2018-05-25 18:38                 ` Ævar Arnfjörð Bjarmason
2018-05-26 12:49                   ` Duy Nguyen
2018-05-31  7:45             ` Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 0/9] ambiguous checkout UI & checkout.defaultRemote Ævar Arnfjörð Bjarmason
2018-06-01 21:10                 ` [PATCH v5 0/8] " Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 " Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 " Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 1/8] checkout tests: index should be clean after dwim checkout Ævar Arnfjörð Bjarmason
2018-06-05 15:45                       ` SZEDER Gábor
2018-07-27 17:48                         ` [PATCH] tests: make use of the test_must_be_empty function Ævar Arnfjörð Bjarmason
2018-07-27 21:50                           ` Junio C Hamano
2018-07-31  0:17                           ` SZEDER Gábor
2018-08-22 17:48                           ` [PATCH] t6018-rev-list-glob: fix 'empty stdin' test SZEDER Gábor
2018-08-22 17:53                             ` Eric Sunshine
2018-08-22 18:59                               ` SZEDER Gábor
2018-08-22 20:30                                 ` Eric Sunshine
2018-08-22 18:01                             ` Junio C Hamano
2018-08-22 18:50                             ` Junio C Hamano
2018-08-22 19:23                               ` Jeff King
2018-08-22 19:50                                 ` [PATCH] rev-list: make empty --stdin not an error Jeff King
2018-08-22 20:42                                   ` Junio C Hamano
2018-08-22 21:37                                     ` Jeff King
2018-08-22 21:50                                       ` Junio C Hamano
2018-08-22 21:55                                         ` Jeff King
2018-08-22 21:41                                     ` Junio C Hamano
2018-06-05 14:40                     ` [PATCH v7 2/8] checkout.h: wrap the arguments to unique_tracking_name() Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 3/8] checkout.c: introduce an *_INIT macro Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 4/8] checkout.c: change "unique" member to "num_matches" Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 5/8] checkout: pass the "num_matches" up to callers Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 6/8] builtin/checkout.c: use "ret" variable for return Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 7/8] checkout: add advice for ambiguous "checkout <branch>" Ævar Arnfjörð Bjarmason
2018-06-05 14:40                     ` [PATCH v7 8/8] checkout & worktree: introduce checkout.defaultRemote Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 1/8] checkout tests: index should be clean after dwim checkout Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 2/8] checkout.h: wrap the arguments to unique_tracking_name() Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 3/8] checkout.c: introduce an *_INIT macro Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 4/8] checkout.c]: change "unique" member to "num_matches" Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 5/8] checkout: pass the "num_matches" up to callers Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 6/8] builtin/checkout.c: use "ret" variable for return Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 7/8] checkout: add advice for ambiguous "checkout <branch>" Ævar Arnfjörð Bjarmason
2018-06-02 11:50                   ` [PATCH v6 8/8] checkout & worktree: introduce checkout.defaultRemote Ævar Arnfjörð Bjarmason
2018-06-03  7:58                     ` Eric Sunshine
2018-06-01 21:10                 ` [PATCH v5 1/8] checkout tests: index should be clean after dwim checkout Ævar Arnfjörð Bjarmason
2018-06-01 21:10                 ` [PATCH v5 2/8] checkout.h: wrap the arguments to unique_tracking_name() Ævar Arnfjörð Bjarmason
2018-06-01 21:10                 ` [PATCH v5 3/8] checkout.[ch]: introduce an *_INIT macro Ævar Arnfjörð Bjarmason
2018-06-01 22:40                   ` Eric Sunshine
2018-06-01 21:10                 ` [PATCH v5 4/8] checkout.[ch]: change "unique" member to "num_matches" Ævar Arnfjörð Bjarmason
2018-06-01 22:41                   ` Eric Sunshine
2018-06-01 21:10                 ` [PATCH v5 5/8] checkout: pass the "num_matches" up to callers Ævar Arnfjörð Bjarmason
2018-06-01 21:10                 ` [PATCH v5 6/8] builtin/checkout.c: use "ret" variable for return Ævar Arnfjörð Bjarmason
2018-06-01 21:10                 ` [PATCH v5 7/8] checkout: add advice for ambiguous "checkout <branch>" Ævar Arnfjörð Bjarmason
2018-06-01 22:52                   ` Eric Sunshine
2018-06-01 21:10                 ` [PATCH v5 8/8] checkout & worktree: introduce checkout.defaultRemote Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 1/9] checkout tests: index should be clean after dwim checkout Ævar Arnfjörð Bjarmason
2018-06-01  4:06                 ` Junio C Hamano
2018-06-01 19:43                   ` Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 2/9] checkout.h: wrap the arguments to unique_tracking_name() Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 3/9] checkout.[ch]: move struct declaration into *.h Ævar Arnfjörð Bjarmason
2018-05-31 21:45                 ` Thomas Gummerer
2018-06-01  2:14                   ` Junio C Hamano
2018-06-01  9:56                     ` Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 4/9] checkout.[ch]: introduce an *_INIT macro Ævar Arnfjörð Bjarmason
2018-06-01  4:16                 ` Junio C Hamano
2018-05-31 19:52               ` [PATCH v4 5/9] checkout.[ch]: change "unique" member to "num_matches" Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 6/9] checkout: pass the "num_matches" up to callers Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 7/9] builtin/checkout.c: use "ret" variable for return Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 8/9] checkout: add advice for ambiguous "checkout <branch>" Ævar Arnfjörð Bjarmason
2018-06-01  4:32                 ` Junio C Hamano
2018-06-01  5:11                   ` Junio C Hamano
2018-06-01  9:54                     ` Ævar Arnfjörð Bjarmason
2018-06-04  1:58                       ` Junio C Hamano
2018-06-01  9:50                   ` Ævar Arnfjörð Bjarmason
2018-06-01  7:53                 ` Eric Sunshine
2018-06-01 19:59                   ` Ævar Arnfjörð Bjarmason
2018-05-31 19:52               ` [PATCH v4 9/9] checkout & worktree: introduce checkout.defaultRemote Ævar Arnfjörð Bjarmason
2018-05-31 21:49                 ` Stefan Beller
2018-06-01  8:04                   ` Eric Sunshine
2018-06-01  9:47                   ` Ævar Arnfjörð Bjarmason
2018-05-31 22:22                 ` Thomas Gummerer
2018-06-01  2:17                   ` Junio C Hamano
2018-05-04  7:14       ` Eric Sunshine [this message]
2018-05-04  7:23         ` [PATCH] checkout & worktree: introduce a core.DWIMRemote setting Eric Sunshine

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='CAPig+cSRBBzXDWMJd5k=ZGOt_ayATWB6fZQrcMqJkP8ja4Tq+g@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=t.gummerer@gmail.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).