threads / discuss / 62031

`git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)

Subject: `git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)

## tl;dr

3 messages between Sep 1, 2024 and Sep 4, 2024.

replies: 2people: 2as markdown or json

Han Jiang· Sep 1, 2024, 10:49 UTC · lore

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)

(`git merge --no-overwrite-ignore` overwrites ignored files when merge with conflict.) cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_"; mkdir --parents -- './repo'; git init './repo' echo '1' >'./repo/file_conflict'; git -C './repo' add './file_conflict'; git -C './repo' commit -m "$((++number))" git -C './repo' branch branch2 git -C './repo' checkout -b branch1; echo 'file' >'./repo/.gitignore'; git -C './repo' add './.gitignore'; echo '2' >'./repo/file_conflict'; git -C './repo' add './file_conflict'; git -C './repo' commit -m "$((++number))" git -C './repo' checkout branch2; echo '1' >'./repo/file'; git -C './repo' add './file'; echo '3' >'./repo/file_conflict'; git -C './repo' add './file_conflict'; git -C './repo' commit -m "$((++number))" git -C './repo' checkout branch1 echo '2' >'./repo/file'; git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file' git -C './repo' merge -m "$((++number))" --no-overwrite-ignore branch2 git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file'

(`git merge --no-overwrite-ignore` overwrites ignored files when merge without conflict.) cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_"; mkdir --parents -- './repo'; git init './repo' git -C './repo' commit -m "$((++number))" --allow-empty git -C './repo' branch branch2 git -C './repo' checkout -b branch1; echo 'file' >'./repo/.gitignore'; git -C './repo' add './.gitignore'; git -C './repo' commit -m "$((++number))" git -C './repo' checkout branch2; echo '1' >'./repo/file'; git -C './repo' add './file'; git -C './repo' commit -m "$((++number))" git -C './repo' checkout branch1 echo '2' >'./repo/file'; git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file' git -C './repo' merge -m "$((++number))" --no-overwrite-ignore branch2 git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file'

What did you expect to happen? (Expected behavior)

`git merge --no-overwrite-ignore` refuses to overwrite ignored files when merge with conflict. `git merge --no-overwrite-ignore` refuses to overwrite ignored files when merge without conflict.

What happened instead? (Actual behavior)

`git merge --no-overwrite-ignore` overwrites ignored files when merge with conflict. `git merge --no-overwrite-ignore` overwrites ignored files when merge without conflict.

What's different between what you expected and what actually happened?
Anything else you want to add:

(`git merge --no-overwrite-ignore` refuses to overwrite ignored files when fast-forward.) cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_"; mkdir --parents -- './repo'; git init './repo' branch_default_path="$(git -C './repo' symbolic-ref HEAD)" branch_default_name="${branch_default_path#'refs/heads/'}" echo 'file' >'./repo/.gitignore'; git -C './repo' add './.gitignore'; git -C './repo' commit -m "$((++number))" git -C './repo' branch branch1 rm './repo/.gitignore'; git -C './repo' add './.gitignore'; echo '1'

>'./repo/file'; git -C './repo' add './file'; git -C './repo' commit

-m "$((++number))" git -C './repo' checkout branch1 echo '2' >'./repo/file'; git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file' git -C './repo' merge -m "$((++number))" --no-overwrite-ignore "$branch_default_name" git -C './repo' log --graph --all --patch git -C './repo' status --verbose --verbose cat './repo/file'

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.46.0.windows.1
cpu: x86_64
built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.9.0
OpenSSL: OpenSSL 3.2.2 4 Jun 2024
zlib: 1.3.1
uname: Windows 10.0 22631
compiler info: gnuc: 14.1
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks] not run from a git repository - no hooks to show

Elijah Newren· Sep 3, 2024, 23:19 UTC · re: Han Jiang · lore

Re: `git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)

On Sun, Sep 1, 2024, 03:49 Han Jiang <jhcarl0814@gmail.com> wrote:
Show 11 quoted lines
>
> 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)
>
> (`git merge --no-overwrite-ignore` overwrites ignored files when merge
> with conflict.)
>
> (`git merge --no-overwrite-ignore` overwrites ignored files when merge
> without conflict.)

Yep, well-known issue that I've mentioned multiple times. Somewhat related to the "precious" concept that has come up on the list a few times. See e.g.

  * the "merge backends" section of
https://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/
  * C2-C7 of https://lore.kernel.org/git/CABPp-BEg6vxiUp
  * affects cherry-pick too, with discussion of how merge is affected:
https://lore.kernel.org/git/CABPp-BG=pm8gfRZNW8Rk1V77s40Do1FZy0mxH6epubHbzF8U5w@mail.gmail.com/
  * merge and other shortcomings mentioned when fixing up default
handling of ignored files:
https://lore.kernel.org/git/b7fe354effff8da3de53bd9cc40a03b5fd455f67.1632760428.git.gitgitgadget@gmail.com/
  * wider discussion of correctly removing or keeping files (also
discussing merge), in a series fixing lots of bugs in the area:
https://lore.kernel.org/git/pull.1036.v3.git.1632760428.gitgitgadget@gmail.com/
Han Jiang· Sep 4, 2024, 11:03 UTC · re: Elijah Newren · lore

Re: `git merge --no-overwrite-ignore` overwrites ignored files when merge (i.e. not fast-forward)

(https://lore.kernel.org/git/CABPp-BEg6vxiUp/ says: Message-ID <CABPp-BEg6vxiUp> not found) Many thanks to your leading me to the "Precious Files Design Document" and all the other links! The document reveals that untracked files would better be further subdivided and explains the meaning of each category. Really clear and understandable! Turns out that the support of --[no-]overwrite-ignore is not enough (only works with the fast-forwarding backend), so maybe users have to wait until they deal with all those issues in a unified way.

On Wed, Sep 4, 2024 at 11:19 AM Elijah Newren <newren@gmail.com> wrote:
Show 30 quoted lines
>
> On Sun, Sep 1, 2024, 03:49 Han Jiang <jhcarl0814@gmail.com> wrote:
> >
> > 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)
> >
> > (`git merge --no-overwrite-ignore` overwrites ignored files when merge
> > with conflict.)
> >
> > (`git merge --no-overwrite-ignore` overwrites ignored files when merge
> > without conflict.)
>
>
> Yep, well-known issue that I've mentioned multiple times.  Somewhat
> related to the "precious" concept that has come up on the list a few
> times.  See e.g.
>
>   * the "merge backends" section of
> https://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/
>   * C2-C7 of https://lore.kernel.org/git/CABPp-BEg6vxiUp
>   * affects cherry-pick too, with discussion of how merge is affected:
> https://lore.kernel.org/git/CABPp-BG=pm8gfRZNW8Rk1V77s40Do1FZy0mxH6epubHbzF8U5w@mail.gmail.com/
>   * merge and other shortcomings mentioned when fixing up default
> handling of ignored files:
> https://lore.kernel.org/git/b7fe354effff8da3de53bd9cc40a03b5fd455f67.1632760428.git.gitgitgadget@gmail.com/
>   * wider discussion of correctly removing or keeping files (also
> discussing merge), in a series fixing lots of bugs in the area:
> https://lore.kernel.org/git/pull.1036.v3.git.1632760428.gitgitgadget@gmail.com/

← back to recent threads