{"thread":{"id":"59594","subject":"Git bug","startedAt":"2023-04-14T09:41:37Z","lastAt":"2023-04-17T09:47:42Z","messageCount":3,"participants":["Gabriel Furstenheim Milerud","René Scharfe"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"475351","messageId":"CAJN3DWriXWYKyf+hJL+wZDCgwOZZsWRah=E8_HnKEWh1wcy4Ww@mail.gmail.com","threadId":"59594","inReplyTo":null,"subject":"Git bug","fromName":"Gabriel Furstenheim Milerud","fromEmail":"furstenheim@gmail.com","sentAt":"2023-04-14T09:41:21Z","receivedAt":"2023-04-14T09:41:37Z","isPatch":false,"sender":{"key":"furstenheim@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n> repository in branch A\ngit name-rev $(git rev-parse HEAD) --name-only\n> returns A\ngit checkout B\ngit name-rev $(git rev-parse HEAD) --name-only\n\n\n\nWhat did you expect to happen? (Expected behavior)\nIt should return B\n\nWhat happened instead? (Actual behavior)\nIt returns A\n\nWhat's different between what you expected and what actually happened?\ngit rev-parse does not seem to update. Same is happenning with git\nrev-parse @{-1}\n\nAnything else you want to add:\ngit version 2.34.1\n\nI recently migrated to ubuntu 22. In ubuntu 18 with previous git\nversion is was working as expected.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.34.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.19.0-38-generic #39~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC\nFri Mar 17 21:16:15 UTC 2 x86_64\ncompiler info: gnuc: 11.3\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n"},{"id":"475388","messageId":"43997e66-4afb-562d-c06f-ec3d038f1988@web.de","threadId":"59594","inReplyTo":"CAJN3DWriXWYKyf+hJL+wZDCgwOZZsWRah=E8_HnKEWh1wcy4Ww@mail.gmail.com","subject":"Re: Git bug","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2023-04-14T16:07:24Z","receivedAt":"2023-04-14T16:07:32Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 14.04.23 um 11:41 schrieb Gabriel Furstenheim Milerud:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>> repository in branch A\n> git name-rev $(git rev-parse HEAD) --name-only\n>> returns A\n> git checkout B\n> git name-rev $(git rev-parse HEAD) --name-only\n>\n>\n>\n> What did you expect to happen? (Expected behavior)\n> It should return B\n>\n> What happened instead? (Actual behavior)\n> It returns A\n\nDo you have a short recipe for creating the branches to reproduce this\nbehavior?  Here's my (failed) attempt:\n\n   # create repository\n   git init -q /tmp/repo\n   cd /tmp/repo\n\n   # create branch a\n   echo a >a\n   git add a\n   git commit -q -m a\n   git branch a\n\n   # create branch b\n   echo b >b\n   git add b\n   git commit -q -m b\n   git branch b\n\nWith that done Git v2.34.1 gives me the output you expect:\n\n   $ git switch a\n   Switched to branch 'a'\n   $ git name-rev $(git rev-parse HEAD) --name-only\n   a\n\n   $ git switch b\n   Switched to branch 'b'\n   $ git name-rev $(git rev-parse HEAD) --name-only\n   b\n\n> What's different between what you expected and what actually happened?\n> git rev-parse does not seem to update. Same is happenning with git\n> rev-parse @{-1}\n\n   $ git name-rev $(git rev-parse @{-1}) --name-only\n   a\n\nThis is expected because @{-1} means the branch/commit checked out\nbefore the current one.\n\nWhat does \"git rev-parse HEAD\" return for you in each case?  Do your\nbranches perhaps have the same HEAD commit?\n\n> Anything else you want to add:\n> git version 2.34.1\n>\n> I recently migrated to ubuntu 22. In ubuntu 18 with previous git\n> version is was working as expected.\n\nI guess you use LTS releases, i.e. jammy (22.04) and bionic (18.04)?\nbionic shipped with Git 2.17.1 according to https://packages.ubuntu.com/\n\nRené\n\n"},{"id":"475515","messageId":"CAJN3DWoZcKP-Ft=fPvKeCgtGgfEGMrbSmfMaATjH_cuKRPbnpA@mail.gmail.com","threadId":"59594","inReplyTo":"CAJN3DWpvh8uHnRFnaPgg8U6dW=3xP9YULBe-xfeTAg2SV7K+oQ@mail.gmail.com","subject":"Re: Git bug","fromName":"Gabriel Furstenheim Milerud","fromEmail":"furstenheim@gmail.com","sentAt":"2023-04-17T09:46:39Z","receivedAt":"2023-04-17T09:47:42Z","isPatch":false,"sender":{"key":"furstenheim@gmail.com","avatar":null},"body":"In case someone stumbles onto this. The right way to do it is:\n\ngit rev-parse --symbolic-full-name --abbrev-ref=loose @{-1}\n\nOn Sat, 15 Apr 2023 at 11:00, Gabriel Furstenheim Milerud\n<furstenheim@gmail.com> wrote:\n>\n> Sorry, my bad. I didn't realize that it worked based on commits. I got confused by git checkout -, which doesn't.\n>\n> Cheers\n>\n> On Fri, 14 Apr 2023, 18:07 René Scharfe, <l.s.r@web.de> wrote:\n>>\n>> Am 14.04.23 um 11:41 schrieb Gabriel Furstenheim Milerud:\n>> > Thank you for filling out a Git bug report!\n>> > Please answer the following questions to help us understand your issue.\n>> >\n>> > What did you do before the bug happened? (Steps to reproduce your issue)\n>> >> repository in branch A\n>> > git name-rev $(git rev-parse HEAD) --name-only\n>> >> returns A\n>> > git checkout B\n>> > git name-rev $(git rev-parse HEAD) --name-only\n>> >\n>> >\n>> >\n>> > What did you expect to happen? (Expected behavior)\n>> > It should return B\n>> >\n>> > What happened instead? (Actual behavior)\n>> > It returns A\n>>\n>> Do you have a short recipe for creating the branches to reproduce this\n>> behavior?  Here's my (failed) attempt:\n>>\n>>    # create repository\n>>    git init -q /tmp/repo\n>>    cd /tmp/repo\n>>\n>>    # create branch a\n>>    echo a >a\n>>    git add a\n>>    git commit -q -m a\n>>    git branch a\n>>\n>>    # create branch b\n>>    echo b >b\n>>    git add b\n>>    git commit -q -m b\n>>    git branch b\n>>\n>> With that done Git v2.34.1 gives me the output you expect:\n>>\n>>    $ git switch a\n>>    Switched to branch 'a'\n>>    $ git name-rev $(git rev-parse HEAD) --name-only\n>>    a\n>>\n>>    $ git switch b\n>>    Switched to branch 'b'\n>>    $ git name-rev $(git rev-parse HEAD) --name-only\n>>    b\n>>\n>> > What's different between what you expected and what actually happened?\n>> > git rev-parse does not seem to update. Same is happenning with git\n>> > rev-parse @{-1}\n>>\n>>    $ git name-rev $(git rev-parse @{-1}) --name-only\n>>    a\n>>\n>> This is expected because @{-1} means the branch/commit checked out\n>> before the current one.\n>>\n>> What does \"git rev-parse HEAD\" return for you in each case?  Do your\n>> branches perhaps have the same HEAD commit?\n>>\n>> > Anything else you want to add:\n>> > git version 2.34.1\n>> >\n>> > I recently migrated to ubuntu 22. In ubuntu 18 with previous git\n>> > version is was working as expected.\n>>\n>> I guess you use LTS releases, i.e. jammy (22.04) and bionic (18.04)?\n>> bionic shipped with Git 2.17.1 according to https://packages.ubuntu.com/\n>>\n>> René\n>>\n"}]}