{"thread":{"id":"57621","subject":"fast forward merge anomaly, 'commit' after 'reset --soft' can produce new commit with same hash as before","startedAt":"2022-03-26T14:23:36Z","lastAt":"2022-03-26T14:23:36Z","messageCount":1,"participants":["Maximilian Reichel"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"452409","messageId":"1BD801F4-B2BA-4D6C-A450-5EEB14E8A58A@icloud.com","threadId":"57621","inReplyTo":null,"subject":"fast forward merge anomaly, 'commit' after 'reset --soft' can produce new commit with same hash as before","fromName":"Maximilian Reichel","fromEmail":"reichemn@icloud.com","sentAt":"2022-03-26T14:23:24Z","receivedAt":"2022-03-26T14:23:36Z","isPatch":false,"sender":{"key":"reichemn@icloud.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)\nRunning the following script with and without the sleep command.\n```\n#!/bin/bash\ngit -c init.defaultBranch=master init\ngit config user.email \"e@mail.com\"\ngit config  user.name \"Name\"\ngit commit -m init --allow-empty\ngit checkout -b otherBranch\ngit commit -a --allow-empty -m first\ngit checkout master\ngit merge --ff otherBranch\ngit notes add -m foo\n# sleep 2\ngit reset --soft HEAD~1\ngit commit -a --allow-empty -m first\ngit notes add -f -m bar\ngit log --graph --abbrev-commit --decorate --all\ngit checkout otherBranch\ngit notes show\n```\n\nWhat did you expect to happen? (Expected behavior)\nI expected that the sleep command will not affect the behavior of the script.\n\nWhat happened instead? (Actual behavior)\nWithout the sleep command, the note attached to the HEAD of otherBranch contains the message \"bar\" (most of the time).\nWith the sleep command, the note attached to the HEAD of otherBranch contains the message \"foo\". \n\nWhat's different between what you expected and what actually happened?\nWithout the sleep command, the last commit will have the same commit id as the HEAD before the reset.\nBecause of this collision, we can not attach notes to HEAD of the master and the HEAD of otherBranch independently.\n\nAnything else you want to add:\nI tested this on git 2.35.1, 2.30.2 and 2.21.0, and they are all affected. \nI attached the console output of the script with and without the sleep command to this mail.\n\n[System Info]\ngit version:\ngit version 2.35.1\ncpu: x86_64\nbuilt from commit: 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64\ncompiler info: gnuc: 10.2\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): <unset>\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n\n\nwarning: templates not found in /usr/local/share/git-core/templates\nInitialized empty Git repository in /test/state.ff/.git/\n[master (root-commit) c298c33] init\nSwitched to a new branch 'otherBranch'\n[otherBranch ae621d9] first\nSwitched to branch 'master'\nUpdating c298c33..ae621d9\nFast-forward\n[master 1681165] first\n* commit 1681165 (HEAD -> master)\n| Author: Name <e@mail.com>\n| Date:   Sat Mar 26 13:35:57 2022 +0000\n| \n|     first\n| \n| Notes:\n|     bar\n|   \n| * commit be3204c (refs/notes/commits)\n| | Author: Name <e@mail.com>\n| | Date:   Sat Mar 26 13:35:57 2022 +0000\n| | \n| |     Notes added by 'git notes add'\n| | \n| * commit aff6c5b\n|   Author: Name <e@mail.com>\n|   Date:   Sat Mar 26 13:35:55 2022 +0000\n|   \n|       Notes added by 'git notes add'\n|   \n| * commit ae621d9 (otherBranch)\n|/  Author: Name <e@mail.com>\n|   Date:   Sat Mar 26 13:35:55 2022 +0000\n|   \n|       first\n|   \n|   Notes:\n|       foo\n| \n* commit c298c33\n  Author: Name <e@mail.com>\n  Date:   Sat Mar 26 13:35:55 2022 +0000\n  \n      init\nSwitched to branch 'otherBranch'\nfoo\n\n\nwarning: templates not found in /usr/local/share/git-core/templates\nInitialized empty Git repository in /test/state.ff/.git/\n[master (root-commit) 2cd4638] init\nSwitched to a new branch 'otherBranch'\n[otherBranch e803e0a] first\nSwitched to branch 'master'\nUpdating 2cd4638..e803e0a\nFast-forward\n[master e803e0a] first\nOverwriting existing notes for object e803e0a4625722bd00efc5ff39b0d70b55ecae30\n* commit e803e0a (HEAD -> master, otherBranch)\n| Author: Name <e@mail.com>\n| Date:   Sat Mar 26 13:35:47 2022 +0000\n| \n|     first\n| \n| Notes:\n|     bar\n| \n* commit 2cd4638\n  Author: Name <e@mail.com>\n  Date:   Sat Mar 26 13:35:47 2022 +0000\n  \n      init\n  \n* commit 21e0b57 (refs/notes/commits)\n| Author: Name <e@mail.com>\n| Date:   Sat Mar 26 13:35:47 2022 +0000\n| \n|     Notes added by 'git notes add'\n| \n* commit a3da577\n  Author: Name <e@mail.com>\n  Date:   Sat Mar 26 13:35:47 2022 +0000\n  \n      Notes added by 'git notes add'\nSwitched to branch 'otherBranch'\nbar\n"}]}