git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] checkout: teach --worktree
Date: Sun, 14 Jun 2020 03:44:39 -0400	[thread overview]
Message-ID: <20200614074439.GA617439@generichostname> (raw)
In-Reply-To: <CAPig+cQ_G+N=mYqO+=7UaAYft27MhZ2_3v8=QzYpDn5hQySp+A@mail.gmail.com>

Hi Eric,

On Sat, Jun 13, 2020 at 10:51:47PM -0400, Eric Sunshine wrote:
> On Sat, Jun 13, 2020 at 10:25 AM Denton Liu <liu.denton@gmail.com> wrote:
> > [...]
> > Teach `git checkout --worktree`, allowing users to checkout files
> > directly into the worktree without affecting the index.
> >
> > Signed-off-by: Denton Liu <liu.denton@gmail.com>
> > ---
> > diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
> > @@ -264,6 +266,12 @@ When switching branches with `--merge`, staged changes may be lost.
> > +-W::
> > +--worktree::
> > +       When writing contents, only modify files in the worktree. Do not
> > +       modify the index. This option is essentially a no-op when used
> > +       without a `<tree-ish>`.
> 
> Why a no-op rather than actually diagnosing that --worktree makes no
> sense in that case and erroring out?

I decided on this behaviour because I assumed that an empty
`git checkout` has `git restore` behaviour but I guess I was mistaken.
I'll change it to error out.

> > diff --git a/t/t2028-checkout-worktree.sh b/t/t2028-checkout-worktree.sh
> > @@ -0,0 +1,51 @@
> > +test_expect_success 'checkout --worktree on a commit' '
> > +       test_when_finished "git reset --hard tip" &&
> > +       git diff HEAD HEAD~ >expect &&
> > +       git checkout --worktree HEAD~ file1 &&
> > +       git diff >actual &&
> > +       test_cmp expect actual &&
> > +       git diff --cached --exit-code &&
> 
> Would the intent be clearer if you used 'test_expect_code' here?
> 
>     test_expect_code 0 git diff --cached --exit-code &&
> 
> Same question for remaining tests.

I'm not really sure that this adds anything. When I read through the
tests, I already expect each command to be successful, i.e. return 0.
I don't see how explicitly documenting for this one command would make
that more clear.

Looking through the test suite, I only see 15 results of
`test_expect_code 0 git diff --exit-code` and all of those are in t4035.
Meanwhile, I see at least 234 instances without the `test_expect_code`.
I believe that we should leave this as-is.

Thanks,

Denton

  reply	other threads:[~2020-06-14  7:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13 14:25 [PATCH] checkout: teach --worktree Denton Liu
2020-06-14  2:51 ` Eric Sunshine
2020-06-14  7:44   ` Denton Liu [this message]
2020-06-14  8:02     ` Denton Liu
2020-06-14 21:37   ` Junio C Hamano
2020-06-14  8:49 ` [PATCH v2] " Denton Liu
2020-06-16 16:01   ` Phillip Wood
2020-06-23 15:55     ` Denton Liu
2020-06-24 10:20       ` Phillip Wood

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

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

  git send-email \
    --in-reply-to=20200614074439.GA617439@generichostname \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    --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.
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 NNTP newsgroup(s).