{"thread":{"id":"57659","subject":"`git checkout` is not a no-op as documented","startedAt":"2022-04-04T21:23:50Z","lastAt":"2022-04-04T21:23:50Z","messageCount":1,"participants":["Maximilian Reichel"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"453058","messageId":"D0A0CC41-C41E-4856-B969-2A6DD3C14079@icloud.com","threadId":"57659","inReplyTo":null,"subject":"`git checkout` is not a no-op as documented","fromName":"Maximilian Reichel","fromEmail":"reichemn@icloud.com","sentAt":"2022-04-04T16:27:53Z","receivedAt":"2022-04-04T21:23:50Z","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 commands:\n```\n#!/bin/bash\ngit -c init.defaultBranch=master init workDir\ncd workDir\ngit commit --allow-empty -m first\ngit checkout -b other\ngit commit --allow-empty -m second\ngit checkout master\ngit merge --no-ff --no-commit other\ngit merge # shows merge in progress\ngit checkout # should be no-op\ngit merge # shows no merge in progress\ngit commit --no-edit # fails\n```\n\nWhat did you expect to happen? (Expected behavior)\nI tried to merge another branch with `--no-ff --no-commit` but used the checkout command before commiting the changes.\nSince the documentation states:\n> You could omit <branch>, in which case the command degenerates to \"check out the current branch\",\n> which is a glorified no-op with rather expensive side-effects to show only the tracking information,\n> if exists, for the current branch.\nI expected that the checkout with omitted <branch> only shows the tracking information and does not change the current states since it is advertised as a no-op.\nSo I expected the following output:\n```\nInitialized empty Git repository in /test/workDir/.git/\n[master (root-commit) c521e9e] first\nSwitched to a new branch 'other'\n[other 617af42] second\nSwitched to branch 'master'\nAutomatic merge went well; stopped before committing as requested\nfatal: You have not concluded your merge (MERGE_HEAD exists).\nPlease, commit your changes before you merge.\nfatal: You have not concluded your merge (MERGE_HEAD exists).\nPlease, commit your changes before you merge.\n[master d2d6409] Merge branch 'other'\n```\n\n\nWhat happened instead? (Actual behavior)\nAfter running the checkout command, I can longer use `git commit` to finish the merge and commit the changes.\nI got the following output:\n```\nInitialized empty Git repository in /test/workDir/.git/\n[master (root-commit) c521e9e] first\nSwitched to a new branch 'other'\n[other 617af42] second\nSwitched to branch 'master'\nAutomatic merge went well; stopped before committing as requested\nfatal: You have not concluded your merge (MERGE_HEAD exists).\nPlease, commit your changes before you merge.\nfatal: No remote for the current branch.\nOn branch master\nnothing to commit, working tree clean\n```\n\nWhat's different between what you expected and what actually happened?\nI expected `git checkout` to only show the tracking information as stated in the documentation.\n\n\nAnything else you want to add:\nI tested this on git 2.35.1 and 2.21.0, which are both affected. \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"}]}