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

Re: [PATCHv3 3/6] merge-recursive: Fix D/F conflicts

From
Elijah Newren <newren@gmail.com>
Date
Jul 8, 2010, 04:34 UTC
Message-ID
<AANLkTim1thwRF5boWeuhRsKpnY3DHAHq1ixIB-5GBIYA@mail.gmail.com>
In-Reply-To
<7v630rt1h3.fsf@alter.siamese.dyndns.org>
On Wed, Jul 7, 2010 at 3:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Style aside, what happens when we cannot cleanly resolve D/F conflicts,
> i.e. when some untracked/modified paths still remain after the earlier
> removal?  We would signal conflict but at that point what happens to the
> files in the working tree that are involved in this new codepath?  They
> are already gone, I presume, and they at least match the original index
> entries, so not much is lost, but what would the recovery procedure out of
> the resulting mess?  "reset --hard"?

That's a really good point, and yes all those files are already gone. However, isn't this already a problem with current git? git does not abort when it detects the D/F conflict, it simply creates the file with an alternate name such as directory/file~branch, and then continues processing all the other entries -- resulting in all those same files under the directory being deleted. So I don't think this patch creates any new problem.

If you want to resolve such a merge by keeping the directory and the files under it, it is possible, though not at all obvious or straightforward: $ git rm --cached file-that-used-to-be-dir $ git status file-that-used-to-be-dir | grep deleted | sed -e s/.*deleted:// | xargs git checkout $(git merge-base HEAD $(cat .git/MERGE_HEAD)) --

I think we could fix this up, now that we have the D/F conflict resolution being handled last: When process_df_entry() detects that there's a directory in the way of the file that needs to be created (and instead warns and creates it with an alternate name), it could also restore those deleted entries at that time. It seems like a bit of unnecessary work to delete and then restore files, but I'm not sure how to get around it given the basic strategy of having unpack_trees do what it can and then trying to fix it up separately.

Elijah
Previous: Junio C HamanoNext: newren@gmail.com
Message 11 of 17 in “[PATCHv3 0/6] D/F conflict fixes”
  1. newren@gmail.comJul 7, 2010
  2. 1/6 Add additional testcases for D/F conflictsnewren@gmail.com, Jul 7, 2010
  3. Junio C HamanoJul 7, 2010
  4. Elijah NewrenJul 8, 2010
  5. Junio C HamanoJul 8, 2010
  6. 2/6 Add a rename + D/F conflict testcasenewren@gmail.com, Jul 7, 2010
  7. Junio C HamanoJul 7, 2010
  8. Elijah NewrenJul 8, 2010
  9. 3/6 merge-recursive: Fix D/F conflictsnewren@gmail.com, Jul 7, 2010
  10. Junio C HamanoJul 7, 2010
  11. Elijah NewrenJul 8, 2010
  12. 4/6 merge_recursive: Fix renames across paths below D/F conflictsnewren@gmail.com, Jul 7, 2010
  13. 5/6 fast-export: Fix output order of D/F changesnewren@gmail.com, Jul 7, 2010
  14. Junio C HamanoJul 7, 2010
  15. Elijah NewrenJul 8, 2010
  16. Junio C HamanoJul 8, 2010
  17. 6/6 fast-import: Improve robustness when D->F changes provided in wrong ordernewren@gmail.com, Jul 7, 2010

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.