From: "Rubén Justo" <rjusto@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>, Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH 2/3] worktree: warn when removing a worktree with orphan commits
Date: Fri, 28 Apr 2023 01:08:00 +0200 [thread overview]
Message-ID: <592c7265-c8af-bd3c-561d-be22e34d61d6@gmail.com> (raw)
In-Reply-To: <xmqqwn1xnahy.fsf@gitster.g>
On 26-abr-2023 22:46:01, Junio C Hamano wrote:
> Rubén Justo <rjusto@gmail.com> writes:
The message: "Previous HEAD position was", which we have since dc9195ac78
(Let git-checkout always drop any detached head, 2007-02-03), describes
a detached HEAD that has been left behind.
In 8e2dc6ac06 (commit: give final warning when reattaching HEAD to leave
commits behind, 2011-02-18) we moved this message to a new function,
orphaned_commit_warning(). We still show the message if the HEAD left
behind is detached. However, if the HEAD left behind is detached _and_
_not connected_ to any ref, instead of the original message, we show a
warning.
In this series, we want to use that function to show the same warning
when the user removes a worktree whose HEAD is detached and _not
connected_ to any ref. However, if the HEAD is detached but connected,
the original message introduced in dc9195ac78 needs to be adjusted.
> > Maybe "HEAD position was" fits for both usages. This is how it would
> > look like:
> > ...
> > I think, if there are no objections or better suggestions, I'll re-roll
> > with "HEAD was at".
This is about the message introduced in dc9195ac78, but...
> But does it convey the more important point? The reason why "HEAD
I think you are referring to the warning.
Starting from a situation like:
$ git checkout -b foo
Switched to a new branch 'foo'
$ git checkout --detach
HEAD is now at 47ab99a
$ git commit --allow-empty -m dangling
[detached HEAD 398a1b0] dangling
$ git worktree add --detach foo-wt
Preparing worktree (detached HEAD 398a1b0)
HEAD is now at 398a1b0 dangling
If we switch to 'foo' in the current worktree, the message is:
$ git checkout foo
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
398a1b0 dangling
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 398a1b0
Switched to branch 'foo'
And -- this is what we are adding in this series -- the same message if
we remove the worktree 'foo-wt':
$ git worktree remove foo-wt
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
398a1b0 dangling
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 398a1b0
> > 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
I apologize, the examples were confusing. I though it was a good idea
to show the new message next to other messages where we also refer to
the HEAD position.
next prev parent reply other threads:[~2023-04-27 23:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 22:10 [PATCH 0/3] warn when unreachable commits are left behind Rubén Justo
2023-04-22 22:19 ` [PATCH 1/3] checkout: move orphaned_commit_warning() Rubén Justo
2023-04-22 22:19 ` [PATCH 2/3] worktree: warn when removing a worktree with orphan commits Rubén Justo
2023-04-24 20:28 ` Junio C Hamano
2023-04-26 22:29 ` Rubén Justo
2023-04-27 5:46 ` Junio C Hamano
2023-04-27 6:16 ` Eric Sunshine
2023-04-28 0:49 ` Junio C Hamano
2023-04-27 23:08 ` Rubén Justo [this message]
2023-04-22 22:19 ` [PATCH 3/3] checkout: warn when unreachable commits after using --orphan Rubén Justo
2023-04-27 0:28 ` Andrei Rybak
2023-04-27 23:09 ` Rubén Justo
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=592c7265-c8af-bd3c-561d-be22e34d61d6@gmail.com \
--to=rjusto@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).