git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] checkout: teach --worktree

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 14, 2020, 02:51 UTC
Message-ID
<CAPig+cQ_G+N=mYqO+=7UaAYft27MhZ2_3v8=QzYpDn5hQySp+A@mail.gmail.com>
In-Reply-To
<d10cb03dd8ce00cb6033c61ff9b9b30bbf5f9c89.1592058281.git.liu.denton@gmail.com>
On Sat, Jun 13, 2020 at 10:25 AM Denton Liu <liu.denton@gmail.com> wrote:
Show 13 quoted lines
> [...]
> 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?

Show 9 quoted lines
> 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.
Previous: Denton LiuNext: Denton Liu
Message 2 of 9 in “checkout: teach --worktree”
  1. checkout: teach --worktreeDenton Liu, Jun 13, 2020
  2. Eric SunshineJun 14, 2020
  3. Denton LiuJun 14, 2020
  4. Denton LiuJun 14, 2020
  5. Junio C HamanoJun 14, 2020
  6. checkout: teach --worktreeDenton Liu, Jun 14, 2020
  7. Phillip WoodJun 16, 2020
  8. Denton LiuJun 23, 2020
  9. Phillip WoodJun 24, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.