git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Jonathan Niedier <jrnieder@gmail.com>
Subject: Re: [PATCH 4/5] status: show the ref that is checked out, even if it's detached
Date: Mon, 4 Mar 2013 19:17:02 +0700	[thread overview]
Message-ID: <CACsJy8A+gw9oJYrJqa-b8noKM7qJTkZEd7ovmxqR68i6miCatA@mail.gmail.com> (raw)
In-Reply-To: <7vy5e49l3i.fsf@alter.siamese.dyndns.org>

On Mon, Mar 4, 2013 at 5:25 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> When a remote ref or a tag is checked out, HEAD is automatically
>> detached. There is no user friendly way to find out what ref is
>> checked out in this case. This patch digs in reflog for this
>> information and shows "Detached from origin/master" or "Detached from
>> v1.8.0" instead of "Currently not on any branch".
>
> "Detached from" is a nice attempt to compromise in the phrasing.
>
> We usually say you detach HEAD at v1.8.0, but what is shown is what
> started from such a state but then the user may have built more
> history on top of it and may no longer be at v1.8.0, so obviously we
> do not want to say "Detached at".  We are in a "detached at v1.8.0
> and then possibly built one or more commits on top" state (would it
> be helpful to differentiate the "nothing built on top" and "some
> commits have been built on top" cases, I wonder).

Hmm.. never thought of that subtlety. Differentiating should be
possible. I'm just not sure if it would be helpful. Comments people,
do or not do?

> Also I wonder if you could do a bit more to help the users who do:
>
>     $ git checkout $(git merge-base HEAD nd/branch-show-rebase-bisect-state)
>
> aka
>
>     $ git checkout ...nd/branch-show-rebase-bisect-state
>
> and then do one or more commits on top.
>
> Instead of punting to "Currently not on any branch", would it help
> to show the place you first detached at, so that the user can then
> grab that commit object name and run
>
>     $ git log --oneline $that_commit..
>
> or something?

$that_commit would be HEAD@{-1} right? Should that be used instead of
grabbing random SHA-1 shown in git-status?


>> +static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
>
> Can't this be done by generalizing grab_nth_branch_switch() and then
> exposing it as part of the general API?

We could share the code, yes. Initially I wanted something that
resolves "@{-1}" and gives me the reflog entry. Maybe we could add a
function to do that.


> I also feel uneasy about two issues this and the previous change

I assume "previous change" is 1/5, reflog format change.


>  2) The previous one records this sequence in a funny way:
>
>         : start from branch A
>         git checkout B
>         git checkout C
>
>     The resulting reflog entries result in
>
>         checkout: moving from A to refs/heads/B
>         checkout: moving from B to refs/heads/C
>
>     even though existing code and tools are expecting to read
>
>         checkout: moving from A to B
>         checkout: moving from B to C

It does not record exactly user input, but the "to" part is basically
extended sha-1 and I don't think current tools parse them manually.
Instead just they should just pass them to git-rev-parse to do the
job. So this change is not really bad. But again the recent '!'
incident in attr.c shows that I know nothing about real world usage.
We could do dwim when parsing the reflog, which introduces no changes
in reflog format.


> By the way, even though the title of this patch is "status: show the
> ref that is checked out, even if it's detached", a quick check with
>
>         $ cd ../linux-3.0
>         $ git describe
>         v3.8-rc7
>         $ ../git.git/git-checkout v3.8-rc7
>         $ tail -n 1 .git/logs/HEAD | sed -e 's/.*checkout/checkout/'
>         checkout: moving from master to refs/tags/v3.8-rc7
>         $ ../git.git/git-status | head -n 1
>         # Not currently on any branch.
>         $ ../git.git/git-branch -v
>         * (no branch) 836dc9e Linux 3.8-rc7
>           master      836dc9e Linux 3.8-rc7
>
> does not seem to give me anything more helpful.

Yeah. I blame myself for copying from interpret_nth_prior_checkout()
without full understanding, and git's poor documentation (there's no
description about for_each_recent_reflog_ent, and that the caller is
supposed to call for_each_reflog_ent in some case; but I think this
convention is unintuitive, for_each_recent_reflog_ent should do that
itself)
-- 
Duy

  reply	other threads:[~2013-03-04 12:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03  9:41 [PATCH 0/5] nd/branch-show-rebase-bisect-state updates Nguyễn Thái Ngọc Duy
2013-03-03  9:41 ` [PATCH 1/5] checkout: record full target ref in reflog Nguyễn Thái Ngọc Duy
2013-03-03  9:41 ` [PATCH 2/5] wt-status: split wt_status_state parsing function out Nguyễn Thái Ngọc Duy
2013-03-03  9:41 ` [PATCH 3/5] wt-status: move wt_status_get_state() out to wt_status_print() Nguyễn Thái Ngọc Duy
2013-03-03  9:41 ` [PATCH 4/5] status: show the ref that is checked out, even if it's detached Nguyễn Thái Ngọc Duy
2013-03-03 22:25   ` Junio C Hamano
2013-03-04 12:17     ` Duy Nguyen [this message]
2013-03-04 15:49       ` Junio C Hamano
2013-03-05 11:39     ` Duy Nguyen
2013-03-05 12:18       ` Matthieu Moy
2013-03-03  9:41 ` [PATCH 5/5] branch: show more information when HEAD is detached Nguyễn Thái Ngọc Duy
2013-03-03 22:28   ` Junio C Hamano
2013-03-06 12:21 ` [PATCH v2 0/4] nd/branch-show-rebase-bisect-state updates Nguyễn Thái Ngọc Duy
2013-03-06 12:21   ` [PATCH v2 1/4] wt-status: split wt_status_state parsing function out Nguyễn Thái Ngọc Duy
2013-03-06 18:48     ` Junio C Hamano
2013-03-06 23:53       ` Junio C Hamano
2013-03-06 12:21   ` [PATCH v2 2/4] wt-status: move wt_status_get_state() out to wt_status_print() Nguyễn Thái Ngọc Duy
2013-03-06 12:21   ` [PATCH v2 3/4] status: show more info than "currently not on any branch" Nguyễn Thái Ngọc Duy
2013-03-06 19:16     ` Junio C Hamano
2013-03-08 11:04       ` Duy Nguyen
2013-03-08 21:46         ` Junio C Hamano
2013-03-06 12:21   ` [PATCH v2 4/4] branch: show more information when HEAD is detached Nguyễn Thái Ngọc Duy
2013-03-06 12:26     ` [PATCH v2 0/4] nd/branch-show-rebase-bisect-state updates Nguyễn Thái Ngọc Duy
2013-03-06 12:26       ` [PATCH v2+ 4/4] branch: show more information when HEAD is detached Nguyễn Thái Ngọc Duy
2013-03-13 11:42   ` [PATCH v3 0/5] nd/branch-show-rebase-bisect-state updates Nguyễn Thái Ngọc Duy
2013-03-13 11:42     ` [PATCH v3 1/5] wt-status: move strbuf into read_and_strip_branch() Nguyễn Thái Ngọc Duy
2013-03-13 16:20       ` Junio C Hamano
2013-03-16  2:12       ` [PATCH v3+ " Nguyễn Thái Ngọc Duy
2013-03-13 11:42     ` [PATCH v3 2/5] wt-status: split wt_status_state parsing function out Nguyễn Thái Ngọc Duy
2013-03-13 11:42     ` [PATCH v3 3/5] wt-status: move wt_status_get_state() out to wt_status_print() Nguyễn Thái Ngọc Duy
2013-03-13 11:42     ` [PATCH v3 4/5] status: show more info than "currently not on any branch" Nguyễn Thái Ngọc Duy
2013-03-13 16:25       ` Junio C Hamano
2013-03-13 11:42     ` [PATCH v3 5/5] branch: show more information when HEAD is detached Nguyễn Thái Ngọc Duy
2013-03-19 18:37     ` [PATCH v3 0/5] nd/branch-show-rebase-bisect-state updates Junio C Hamano
2013-03-20 12:40       ` Duy Nguyen
2013-03-20 14:37         ` Junio C Hamano
2013-03-23  3:52           ` [PATCH] status, branch: fix the misleading "bisecting" message Nguyễn Thái Ngọc Duy
2013-03-24  5:30             ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACsJy8A+gw9oJYrJqa-b8noKM7qJTkZEd7ovmxqR68i6miCatA@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@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.
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 NNTP newsgroup(s).