git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Roy Eldar <royeldar0@gmail.com>
Cc: git@vger.kernel.org, jonathantanmy@google.com
Subject: Re: [PATCH RESEND 2/2] status: improve info for detached HEAD after clone
Date: Wed, 08 Mar 2023 12:42:13 -0800	[thread overview]
Message-ID: <xmqqsfefrn4q.fsf@gitster.g> (raw)
In-Reply-To: <20230308192050.1291-3-royeldar0@gmail.com> (Roy Eldar's message of "Wed, 8 Mar 2023 21:20:50 +0200")

Roy Eldar <royeldar0@gmail.com> writes:

> diff --git a/wt-status.c b/wt-status.c
> index 3162241a57..f0a5fb578a 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1632,6 +1632,13 @@ static int grab_1st_switch(struct object_id *ooid UNUSED,
>  	struct grab_1st_switch_cbdata *cb = cb_data;
>  	const char *target = NULL, *end;
>  
> +	if (skip_prefix(message, "clone: from ", &message)) {
> +		oidcpy(&cb->noid, noid);
> +		strbuf_reset(&cb->buf);
> +		strbuf_add_unique_abbrev(&cb->buf, noid, DEFAULT_ABBREV);
> +		return 1;
> +	}
> +
>  	if (!skip_prefix(message, "checkout: moving from ", &message))
>  		return 0;
>  	target = strstr(message, " to ");

Two comments:

 - The original seems to duplicate the logic already in use for
   parsing @{-1} in object-name.c::grab_nth_branch_switch().

 - Adding new code here would mean that the result of parsing @{-1}
   and what wt_status_get_detached_from() will report becomes
   inconsistent, no?  After such a clone, "git checkout @{-1}" would
   say "there is no @{-1}" but "git status" would say it was
   detached from some hexadecimal object.

Thinking about the latter, I think it does not add much value to say
that we detached from something that is not a ref, so not adding
"clone: from " logic to grab_nth_branch_switch() is probably the
right thing to do anyway.

But then does it even make sense to have this new logic here?

Yes, the head may be detached at some object that is not a local or
remote branch.  But what is so bad about reporting the fact
faithfully, i.e., that we are not on any branch?  What commit object
we are at can be seen by "git show" or "git rev-parse HEAD" or any
other usual ways anyway, so...

I personally do not very much appreciate the extra info that is
given by saying "HEAD detached at X" and "HEAD detached from X",
compared to saying just "Not currently on any branch", especially
when these X are not concrete branch names or tag names but just
hexadecimal string that needs to be fed to "git describe" to be
turned into something that makes sense to humans, and that is
probably the reason why I am not a good judge about the change this
patch makes.  Others who like the "detached at/from X" may be better
judges to decide if this change makes sense.

Thanks.


  reply	other threads:[~2023-03-08 20:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 19:20 [PATCH RESEND 0/2] status: improve info for detached HEAD Roy Eldar
2023-03-08 19:20 ` [PATCH RESEND 1/2] t7508: test status output for detached HEAD after clone Roy Eldar
2023-03-08 19:20 ` [PATCH RESEND 2/2] status: improve info " Roy Eldar
2023-03-08 20:42   ` Junio C Hamano [this message]
2023-03-10 16:25     ` Roy E

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=xmqqsfefrn4q.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    --cc=royeldar0@gmail.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).