Re: [PATCH] checkout: teach --worktree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 13, 2020 at 10:25 AM Denton Liu <liu.denton@xxxxxxxxx> 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@xxxxxxxxx>
> ---
> 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?

> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux