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

Re: [PATCH 2/3] worktree: warn when removing a worktree with orphan commits

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 27, 2023, 06:16 UTC
Message-ID
<CAPig+cRm1XaMzgDQZGS8vwpD_k8srQH0NGmziT_J7mtTHnR7OA@mail.gmail.com>
In-Reply-To
<xmqqwn1xnahy.fsf@gitster.g>
On Thu, Apr 27, 2023 at 1:50 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Whichever phrasing you end up using, I think the order of messages
> should be made consistent between the two cases.  That is,
>
> > Maybe "HEAD position was" fits for both usages.  This is how it would
> > look like:
> >
> >    $ git checkout -
> >    HEAD position was 7906992 commit-b
> >    HEAD is now at 2efe05c commit-a
>
> Here "git checkout" reports the lost HEAD and then the end result.
>
> >    $ git worktree add test --detach && git worktree remove test
> >    Preparing worktree (detached HEAD 2efe05c)
> >    HEAD is now at 2efe05c commit-a
> >    HEAD position was 2efe05c commit-a
>
> But here "git worktree add" reports the end resultfirst and then
> reports the lost HEAD.  It probably should report them in reverse.

There may be a misunderstanding here due to the unfortunate construction of Rubén's example which muddles together the output of `git worktree add` and `git worktree remove`. For clarity, his example should probably have been written:

  $ git worktree add test --detach
  Preparing worktree (detached HEAD 2efe05c)
  HEAD is now at 2efe05c commit-a
  $ git worktree remove test
  HEAD position was 2efe05c commit-a

although showing only the `git worktree remove` command would probably have been even clearer.

Such example output does a good job of arguing in favor of your suggestion to use phrasing which is more alarming:

  $ git checkout -
  Commit 2efe05c "commit-a" left dangling
  HEAD is now at 7906992 commit-b
  $ git worktree remove test
  Commit 2efe05c "commit-a" left dangling

(Hopefully someone can come up with better wording than "About to lose history leading to" and "Commit ... left dangling", neither of which sound quite right.)

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 12 in “warn when unreachable commits are left behind”
  1. 0/3 warn when unreachable commits are left behindRubén Justo, Apr 22, 2023
  2. 1/3 checkout: move orphaned_commit_warning()Rubén Justo, Apr 22, 2023
  3. 2/3 worktree: warn when removing a worktree with orphan commitsRubén Justo, Apr 22, 2023
  4. Junio C HamanoApr 24, 2023
  5. Rubén JustoApr 26, 2023
  6. Junio C HamanoApr 27, 2023
  7. Eric SunshineApr 27, 2023
  8. Junio C HamanoApr 28, 2023
  9. Rubén JustoApr 27, 2023
  10. 3/3 checkout: warn when unreachable commits after using --orphanRubén Justo, Apr 22, 2023
  11. Andrei RybakApr 27, 2023
  12. Rubén JustoApr 27, 2023

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.