git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v1 0/2] Be nicer to the user on tracked/untracked merge conflicts

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2022, 21:16 UTC
Message-ID
<xmqqczh4vp6e.fsf@gitster.g>
In-Reply-To
<20220425202721.20066-1-git.jonathan.bressat@gmail.com>
Jonathan <git.jonathan.bressat@gmail.com> writes:
> Because with this merge still fail for unstaged file that has the same
> content, because unstaged file are not exactly treated the same way.

Correct. If you want to do this correctly, you'd need to make sure that you'd clobber untracked files ONLY when you are not losing any information.

And even with that, I think some existing users will be hurt with this change in a huge way. They may have untracked change locally because they are not quite done with it yet, and somebody else throws a pull request at them that has the same change as the local modification.

They make a trial merge, look at the result, and discard it because there are also unwanted changes in the branch they pulled into.

    $ git pull $URL $branch ;# responding to the pull request
    ... examine the result, finding it unsatisfactory ...
    $ git reset --hard ORIG_HEAD
    ... now we are back to where we started; well not really ...

Now, without this change, "git pull" used to stop until they stashed away the untracked change safely. But with this change, "git pull" will succeed, and then "reset --hard" will discard it together with other changes that came to us from $URL/$branch. They lost their local, uncommitted change.

And "but you can pull the equivalent out of $URL/$branch" is not a good excuse. They may not notice the lossage long after having dealt with this pull request (there are busy people who are handling many pull requests from many people) and they have been relying on "git pull" that never clobbers their local uncommitted changes. And when they noticed the lossage, they may not even remember which one of pull requests happened to have an identical change as their local change to cause this lossage, simply because "git pull" that used to stop just continued without a noise.

So, I am not sure if this is really a good idea to begin with. It certainly would make it slightly simpler in a trivial case, but it surely looks like a dangerous behaviour change, especially if it is done unconditionally.

> Our patch broke some test in t6436-merge-overwrite.sh so we think that
> we need to modify those tests to make them follow the patch.

Wait. Isn't it backwards? The existing tests _may_ be casting an undesirable current behaviour in stone, but most of the time it is protecting existing user's expectations. If you have an untracked file, you can rest assured that they won't be clobbered by a merge.

So we'd need to think twice and carefully examine if it makes sense to update the expectations. I haven't read the change to the tests, so I cannot tell which case it is.

Thanks.
Previous: JonathanNext: Guillaume Cogoni
Message 9 of 27 in “[WIP]: make merge nicer to the user”
  1. Guillaume CogoniMar 27, 2022
  2. 0/1 Be nicer to the user on tracked/untracked merge conflictsJonathan, Apr 12, 2022
  3. 1/1 Merge with untracked file that are the same without failure and testJonathan, Apr 12, 2022
  4. Ævar Arnfjörð BjarmasonApr 12, 2022
  5. Junio C HamanoApr 13, 2022
  6. 0/2 Be nicer to the user on tracked/untracked merge conflictsJonathan, Apr 25, 2022
  7. 1/2 t7615: test how merge behave when there is untracked fileJonathan, Apr 25, 2022
  8. 2/2 merge with untracked file that are the same without failureJonathan, Apr 25, 2022
  9. Junio C HamanoApr 25, 2022
  10. Guillaume CogoniApr 25, 2022
  11. Junio C HamanoApr 25, 2022
  12. Ævar Arnfjörð BjarmasonApr 12, 2022
  13. Jonathan BressatApr 14, 2022
  14. Matthieu MoyApr 26, 2022
  15. Junio C HamanoApr 26, 2022
  16. Jonathan BressatApr 28, 2022
  17. 0/4 Be nicer to the user on tracked/untracked merge conflictsJonathan Bressat, May 27, 2022
  18. 1/4 t6436: tests how merge behave when there is untracked file with the same contentJonathan Bressat, May 27, 2022
  19. 2/4 merge with untracked file that are the same without failureJonathan Bressat, May 27, 2022
  20. 3/4 add configuration variable corresponding to --overwrite-same-contentJonathan Bressat, May 27, 2022
  21. 4/4 error message now advice to use the new optionJonathan Bressat, May 27, 2022
  22. Matthieu MoyApr 26, 2022
  23. Matthieu MoyJun 4, 2022
  24. Guillaume CogoniJun 10, 2022
  25. Matthieu MoyJun 4, 2022
  26. Matthieu MoyJun 4, 2022
  27. Matthieu MoyJun 4, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.