git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Enis Bayramoğlu" <enis@picussecurity.com>
To: Michael J Gruber <git@grubix.eu>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: `git status` output is very misleading after a merge on a "detached HEAD"
Date: Wed, 12 Apr 2017 09:15:47 +0300	[thread overview]
Message-ID: <CAMLReHa2M=h+cWm_9qqiL0n+E1+AFzHXqiBG45fGiGUBTdkseg@mail.gmail.com> (raw)
In-Reply-To: <5704E476-BD11-47D1-A15E-C1E29A1398AD@grubix.eu>

On Wed, Apr 12, 2017 at 8:43 AM, Michael J Gruber <git@grubix.eu> wrote:
> Am 11. April 2017 22:40:14 MESZ schrieb "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>:
>>On Tue, Apr 11, 2017 at 5:13 PM, Enis Bayramoğlu
>><enis@picussecurity.com> wrote:
>>>> Well, what do you suggest as an alternative?
>>>>
>>>> Git tells you that you are in detached state and where you came from
>>>> (detached from).
>>>
>>> I think it'd be best if git status somehow indicated that you're no
>>> longer at the same commit. Maybe something like:
>>>
>>> $ git status
>>> HEAD detached from origin/master, no longer at the same commit
>>> nothing to commit, working directory clean
>>
>>I'm not saying this is clear, I didn't know this until I read the code
>>just now, but for what it's worth it says "detached at" if you're
>>detached from BRANCH but at the same commit, and "detached from" if
>>you're now on a different commit.
>>
>
> That's what I explained in my first reply which the OP quoted in a chopped way.  I think he even misquoted the git output he got.
>
> It's the difference between from and at.

You're right, I hadn't noticed the difference, I really thought I
copied the git output verbatim from the console, but I must've been
confused while switching windows. Sorry about that.

I consider myself fairly fluent in English, but it's not my native
language. If you think head detached "from" vs. "at" is immediately
and unambiguously clear about what's going on, then I guess it's not
worth changing the behavior.

>
>
>>> or, to be more informative
>>>
>>> HEAD detached from origin/master 1 commit ago,
>>
>>In lieu of that, which would need some of the rev-list machinery to be
>>invoked on every git-status, I wonder if just saying "HEAD detached &
>>diverged from origin/master" wouldn't be clearer:
>>
>>diff --git a/wt-status.c b/wt-status.c
>>index 308cf3779e..79c8cfd1cf 100644
>>--- a/wt-status.c
>>+++ b/wt-status.c
>>@@ -1542,7 +1542,7 @@ static void wt_longstatus_print(struct wt_status
>>*s)
>>                                if (state.detached_at)
>>                                      on_what = _("HEAD detached at ");
>>                                else
>>-                                       on_what = _("HEAD detached from
>>");
>>+                                       on_what = _("HEAD detached &
>>diverged from ");
>>                        } else {
>>                                branch_name = "";
>>                           on_what = _("Not currently on any branch.");
>>
>>
>>
>
> No way. That would reduce the information that we give.
>
> Note that the difference between from and at is also: are there commits that we could lose when we switch away, that is: that git checkout would warn us about?
>
> Maybe improve the doc instead?
>
>>
>>> On Tue, Apr 11, 2017 at 5:55 PM, Michael J Gruber <git@grubix.eu>
>>wrote:
>>>> Enis Bayramoğlu venit, vidit, dixit 11.04.2017 10:57:
>>>>> I've encountered a very misleading output from `git status`. Here's
>>a
>>>>> sequence of events that demonstrates the issue:
>>>>>
>>>>> $ git --version
>>>>> git version 2.12.0
>>>>>
>>>>> $ git checkout origin/master
>>>>>
>>>>> $ git status
>>>>> HEAD detached from origin/master
>>>>> nothing to commit, working directory clean
>>>>
>>>> Hmm. My Git would display "detached at" here as long as you are on
>>the
>>>> commit that you detached from.
>>>>
>>>>> $ git merge --ff f3515b749be861b57fc70c2341c1234eeb0d5b87
>>>>>
>>>>> $ git status
>>>>> HEAD detached from origin/master
>>>>> nothing to commit, working directory clean
>>>>>
>>>>> $ git rev-parse origin/master
>>>>> e1dc1baaadee0f1aef2d5c45d068306025d11f67
>>>>>
>>>>> $ git rev-parse HEAD
>>>>> 786cb6dd09897e0950a2bdc971f0665a059efd33
>>>>>
>>>>> I think it's extremely misleading that `git status` simply reports
>>>>> "HEAD detached from origin/master" while this simply happens to be
>>a
>>>>> mildly relevant fact about some past state.
>>>>>
>>>>> Thanks and regards
>>>>>
>>>>
>>>> Well, what do you suggest as an alternative?
>>>>
>>>> Git tells you that you are in detached state and where you came from
>>>> (detached from).
>>>>
>>>> Michael
>

Thanks,
Enis

  reply	other threads:[~2017-04-12  6:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11  8:57 `git status` output is very misleading after a merge on a "detached HEAD" Enis Bayramoğlu
2017-04-11 14:55 ` Michael J Gruber
2017-04-11 15:13   ` Enis Bayramoğlu
2017-04-11 20:40     ` Ævar Arnfjörð Bjarmason
2017-04-12  5:43       ` Michael J Gruber
2017-04-12  6:15         ` Enis Bayramoğlu [this message]
2017-04-12 11:36           ` Michael J Gruber
2017-04-12 12:18         ` Ævar Arnfjörð Bjarmason
2017-04-12 13:11           ` Michael J Gruber
2017-04-12 13:30             ` Ævar Arnfjörð Bjarmason
2017-04-14 16:25             ` Philip Oakley

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='CAMLReHa2M=h+cWm_9qqiL0n+E1+AFzHXqiBG45fGiGUBTdkseg@mail.gmail.com' \
    --to=enis@picussecurity.com \
    --cc=avarab@gmail.com \
    --cc=git@grubix.eu \
    --cc=git@vger.kernel.org \
    /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).