From: Gabriel Furstenheim Milerud <furstenheim@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: git@vger.kernel.org
Subject: Re: Git bug
Date: Mon, 17 Apr 2023 11:46:39 +0200 [thread overview]
Message-ID: <CAJN3DWoZcKP-Ft=fPvKeCgtGgfEGMrbSmfMaATjH_cuKRPbnpA@mail.gmail.com> (raw)
In-Reply-To: <CAJN3DWpvh8uHnRFnaPgg8U6dW=3xP9YULBe-xfeTAg2SV7K+oQ@mail.gmail.com>
In case someone stumbles onto this. The right way to do it is:
git rev-parse --symbolic-full-name --abbrev-ref=loose @{-1}
On Sat, 15 Apr 2023 at 11:00, Gabriel Furstenheim Milerud
<furstenheim@gmail.com> wrote:
>
> Sorry, my bad. I didn't realize that it worked based on commits. I got confused by git checkout -, which doesn't.
>
> Cheers
>
> On Fri, 14 Apr 2023, 18:07 René Scharfe, <l.s.r@web.de> wrote:
>>
>> Am 14.04.23 um 11:41 schrieb Gabriel Furstenheim Milerud:
>> > Thank you for filling out a Git bug report!
>> > Please answer the following questions to help us understand your issue.
>> >
>> > What did you do before the bug happened? (Steps to reproduce your issue)
>> >> repository in branch A
>> > git name-rev $(git rev-parse HEAD) --name-only
>> >> returns A
>> > git checkout B
>> > git name-rev $(git rev-parse HEAD) --name-only
>> >
>> >
>> >
>> > What did you expect to happen? (Expected behavior)
>> > It should return B
>> >
>> > What happened instead? (Actual behavior)
>> > It returns A
>>
>> Do you have a short recipe for creating the branches to reproduce this
>> behavior? Here's my (failed) attempt:
>>
>> # create repository
>> git init -q /tmp/repo
>> cd /tmp/repo
>>
>> # create branch a
>> echo a >a
>> git add a
>> git commit -q -m a
>> git branch a
>>
>> # create branch b
>> echo b >b
>> git add b
>> git commit -q -m b
>> git branch b
>>
>> With that done Git v2.34.1 gives me the output you expect:
>>
>> $ git switch a
>> Switched to branch 'a'
>> $ git name-rev $(git rev-parse HEAD) --name-only
>> a
>>
>> $ git switch b
>> Switched to branch 'b'
>> $ git name-rev $(git rev-parse HEAD) --name-only
>> b
>>
>> > What's different between what you expected and what actually happened?
>> > git rev-parse does not seem to update. Same is happenning with git
>> > rev-parse @{-1}
>>
>> $ git name-rev $(git rev-parse @{-1}) --name-only
>> a
>>
>> This is expected because @{-1} means the branch/commit checked out
>> before the current one.
>>
>> What does "git rev-parse HEAD" return for you in each case? Do your
>> branches perhaps have the same HEAD commit?
>>
>> > Anything else you want to add:
>> > git version 2.34.1
>> >
>> > I recently migrated to ubuntu 22. In ubuntu 18 with previous git
>> > version is was working as expected.
>>
>> I guess you use LTS releases, i.e. jammy (22.04) and bionic (18.04)?
>> bionic shipped with Git 2.17.1 according to https://packages.ubuntu.com/
>>
>> René
>>
next prev parent reply other threads:[~2023-04-17 9:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 9:41 Git bug Gabriel Furstenheim Milerud
2023-04-14 16:07 ` René Scharfe
[not found] ` <CAJN3DWpvh8uHnRFnaPgg8U6dW=3xP9YULBe-xfeTAg2SV7K+oQ@mail.gmail.com>
2023-04-17 9:46 ` Gabriel Furstenheim Milerud [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-08 19:32 git bug Justin Tang
2024-02-04 23:42 moti sd
2024-02-05 6:47 ` Patrick Steinhardt
2023-04-14 8:29 Git bug Gabriel Furstenheim Milerud
2023-04-14 9:26 ` Kristoffer Haugsbakk
2020-08-06 14:59 git bug PANEL Christian
2020-08-06 14:48 PANEL Christian
2020-08-06 20:23 ` René Scharfe
2020-08-07 0:02 ` Jeff King
2020-08-10 5:56 ` René Scharfe
2020-08-10 17:20 ` PANEL Christian
2012-10-22 16:28 git BUG Коньков Евгений
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='CAJN3DWoZcKP-Ft=fPvKeCgtGgfEGMrbSmfMaATjH_cuKRPbnpA@mail.gmail.com' \
--to=furstenheim@gmail.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
/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).