{"thread":{"id":"62031","subject":"`git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)","startedAt":"2024-09-01T10:49:19Z","lastAt":"2024-09-04T11:03:47Z","messageCount":3,"participants":["Han Jiang","Elijah Newren"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"501954","messageId":"CANrWfmRvtz=WOPpv54-22aEFsCPi_vwpFo_Q08vq31NjggOVsw@mail.gmail.com","threadId":"62031","inReplyTo":null,"subject":"`git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-01T10:49:05Z","receivedAt":"2024-09-01T10:49:19Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"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\n(`git merge --no-overwrite-ignore` overwrites ignored files when merge\nwith conflict.)\ncd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\nmkdir --parents -- './repo';\ngit init './repo'\necho '1' >'./repo/file_conflict'; git -C './repo' add\n'./file_conflict'; git -C './repo' commit -m \"$((++number))\"\ngit -C './repo' branch branch2\ngit -C './repo' checkout -b branch1; echo 'file' >'./repo/.gitignore';\ngit -C './repo' add './.gitignore'; echo '2' >'./repo/file_conflict';\ngit -C './repo' add './file_conflict'; git -C './repo' commit -m\n\"$((++number))\"\ngit -C './repo' checkout branch2; echo '1' >'./repo/file'; git -C\n'./repo' add './file'; echo '3' >'./repo/file_conflict'; git -C\n'./repo' add './file_conflict'; git -C './repo' commit -m\n\"$((++number))\"\ngit -C './repo' checkout branch1\necho '2' >'./repo/file';\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\ngit -C './repo' merge -m \"$((++number))\" --no-overwrite-ignore branch2\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\n\n(`git merge --no-overwrite-ignore` overwrites ignored files when merge\nwithout conflict.)\ncd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\nmkdir --parents -- './repo';\ngit init './repo'\ngit -C './repo' commit -m \"$((++number))\" --allow-empty\ngit -C './repo' branch branch2\ngit -C './repo' checkout -b branch1; echo 'file' >'./repo/.gitignore';\ngit -C './repo' add './.gitignore'; git -C './repo' commit -m\n\"$((++number))\"\ngit -C './repo' checkout branch2; echo '1' >'./repo/file'; git -C\n'./repo' add './file'; git -C './repo' commit -m \"$((++number))\"\ngit -C './repo' checkout branch1\necho '2' >'./repo/file';\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\ngit -C './repo' merge -m \"$((++number))\" --no-overwrite-ignore branch2\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\n\nWhat did you expect to happen? (Expected behavior)\n\n`git merge --no-overwrite-ignore` refuses to overwrite ignored files\nwhen merge with conflict.\n`git merge --no-overwrite-ignore` refuses to overwrite ignored files\nwhen merge without conflict.\n\nWhat happened instead? (Actual behavior)\n\n`git merge --no-overwrite-ignore` overwrites ignored files when merge\nwith conflict.\n`git merge --no-overwrite-ignore` overwrites ignored files when merge\nwithout conflict.\n\nWhat's different between what you expected and what actually happened?\n\nAnything else you want to add:\n\n(`git merge --no-overwrite-ignore` refuses to overwrite ignored files\nwhen fast-forward.)\ncd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\nmkdir --parents -- './repo';\ngit init './repo'\nbranch_default_path=\"$(git -C './repo' symbolic-ref HEAD)\"\nbranch_default_name=\"${branch_default_path#'refs/heads/'}\"\necho 'file' >'./repo/.gitignore'; git -C './repo' add './.gitignore';\ngit -C './repo' commit -m \"$((++number))\"\ngit -C './repo' branch branch1\nrm './repo/.gitignore'; git -C './repo' add './.gitignore'; echo '1'\n>'./repo/file'; git -C './repo' add './file'; git -C './repo' commit\n-m \"$((++number))\"\ngit -C './repo' checkout branch1\necho '2' >'./repo/file';\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\ngit -C './repo' merge -m \"$((++number))\" --no-overwrite-ignore\n\"$branch_default_name\"\ngit -C './repo' log --graph --all --patch\ngit -C './repo' status --verbose --verbose\ncat './repo/file'\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.46.0.windows.1\ncpu: x86_64\nbuilt from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nfeature: fsmonitor--daemon\nlibcurl: 8.9.0\nOpenSSL: OpenSSL 3.2.2 4 Jun 2024\nzlib: 1.3.1\nuname: Windows 10.0 22631\ncompiler info: gnuc: 14.1\nlibc info: no libc information available\n$SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"},{"id":"502081","messageId":"CABPp-BEwLYhfBN6esMdeTcby4=12zhFeSqrih-WPy8D+pW3sxQ@mail.gmail.com","threadId":"62031","inReplyTo":"CANrWfmRvtz=WOPpv54-22aEFsCPi_vwpFo_Q08vq31NjggOVsw@mail.gmail.com","subject":"Re: `git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2024-09-03T23:19:00Z","receivedAt":"2024-09-03T23:19:47Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Sun, Sep 1, 2024, 03:49 Han Jiang <jhcarl0814@gmail.com> wrote:\n>\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>\n> (`git merge --no-overwrite-ignore` overwrites ignored files when merge\n> with conflict.)\n>\n> (`git merge --no-overwrite-ignore` overwrites ignored files when merge\n> without conflict.)\n\n\nYep, well-known issue that I've mentioned multiple times.  Somewhat\nrelated to the \"precious\" concept that has come up on the list a few\ntimes.  See e.g.\n\n  * the \"merge backends\" section of\nhttps://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/\n  * C2-C7 of https://lore.kernel.org/git/CABPp-BEg6vxiUp\n  * affects cherry-pick too, with discussion of how merge is affected:\nhttps://lore.kernel.org/git/CABPp-BG=pm8gfRZNW8Rk1V77s40Do1FZy0mxH6epubHbzF8U5w@mail.gmail.com/\n  * merge and other shortcomings mentioned when fixing up default\nhandling of ignored files:\nhttps://lore.kernel.org/git/b7fe354effff8da3de53bd9cc40a03b5fd455f67.1632760428.git.gitgitgadget@gmail.com/\n  * wider discussion of correctly removing or keeping files (also\ndiscussing merge), in a series fixing lots of bugs in the area:\nhttps://lore.kernel.org/git/pull.1036.v3.git.1632760428.gitgitgadget@gmail.com/\n"},{"id":"502108","messageId":"CANrWfmQpUFCkDrdC7k7pMVSY+jow6hePNcd0324PH=T9-WwHsA@mail.gmail.com","threadId":"62031","inReplyTo":"CABPp-BEwLYhfBN6esMdeTcby4=12zhFeSqrih-WPy8D+pW3sxQ@mail.gmail.com","subject":"Re: `git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-04T11:03:34Z","receivedAt":"2024-09-04T11:03:47Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"body":"(https://lore.kernel.org/git/CABPp-BEg6vxiUp/ says: Message-ID\n<CABPp-BEg6vxiUp> not found)\nMany thanks to your leading me to the \"Precious Files Design Document\"\nand all the other links!\nThe document reveals that untracked files would better be further\nsubdivided and explains the meaning of each category. Really clear and\nunderstandable! Turns out that the support of --[no-]overwrite-ignore\nis not enough (only works with the fast-forwarding backend), so maybe\nusers have to wait until they deal with all those issues in a unified\nway.\n\nOn Wed, Sep 4, 2024 at 11:19 AM Elijah Newren <newren@gmail.com> wrote:\n>\n> On Sun, Sep 1, 2024, 03:49 Han Jiang <jhcarl0814@gmail.com> wrote:\n> >\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> >\n> > (`git merge --no-overwrite-ignore` overwrites ignored files when merge\n> > with conflict.)\n> >\n> > (`git merge --no-overwrite-ignore` overwrites ignored files when merge\n> > without conflict.)\n>\n>\n> Yep, well-known issue that I've mentioned multiple times.  Somewhat\n> related to the \"precious\" concept that has come up on the list a few\n> times.  See e.g.\n>\n>   * the \"merge backends\" section of\n> https://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/\n>   * C2-C7 of https://lore.kernel.org/git/CABPp-BEg6vxiUp\n>   * affects cherry-pick too, with discussion of how merge is affected:\n> https://lore.kernel.org/git/CABPp-BG=pm8gfRZNW8Rk1V77s40Do1FZy0mxH6epubHbzF8U5w@mail.gmail.com/\n>   * merge and other shortcomings mentioned when fixing up default\n> handling of ignored files:\n> https://lore.kernel.org/git/b7fe354effff8da3de53bd9cc40a03b5fd455f67.1632760428.git.gitgitgadget@gmail.com/\n>   * wider discussion of correctly removing or keeping files (also\n> discussing merge), in a series fixing lots of bugs in the area:\n> https://lore.kernel.org/git/pull.1036.v3.git.1632760428.gitgitgadget@gmail.com/\n"}]}