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