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

Should "git-read-tree -m -u" delete files?

From
Junio C Hamano <junkio@cox.net>
Date
Jun 24, 2005, 22:08 UTC
Message-ID
<7v1x6rbe6r.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<pan.2005.06.24.13.16.10.406827@smurf.noris.de>
>>>>> "MU" == Matthias Urlichs <smurf@smurf.noris.de> writes:

MU> The only problem I have with it is that "git-read-tree -m -u" MU> doesn't delete files yet. To repeat my question from last week:

>>> Would it be safe to add all files for which
>>> read_tree.c:merge_cache:fn() returns zero to a "delete me" list?

MU> (files on which which then actually get deleted, of course, if g-r-t MU> doesn't find any problems.)

As the guilty party for the "read-tree two-way semantics table" you quoted in your "question from last week" message, I should have replied sooner but could not. Sorry about that [*1*].

Anyway, here are my answers.
 (1) No, merge_function[] returning zero just means "I did not
     cause anything to change the number of already processed
     entries".  When it wants to delete an entry, it explicitly
     marks the entry to be deleted by calling deleted_entry(),
     and the deletion is processed at the very end by
     check_updates() function.  Note that we do _not_ return
     zero in this case.
 (2) The part you quoted in your "last week" message is case 10;
     the current code does delete the path with -u [*2*].
 (3) There could be cases where twoway_merge() does not delete a
     clean path that _should_ be removed.  If that is the case
     then you have spotted a bug --- I would appreciate it if
     you can show a reproduction recipe.  I have looked at the
     function briefly again while writing this reply and did not
     find suspicious code that would just return 0 without
     calling deleted_entry(), though.
 (4) Using --emu23 (followed by git-merge-cache, of course),
     instead of doing "git-read-tree -m -u H M", should remove
     deleted paths as well.
[Footnote]

*1* I was on a crazy travel schedule, going just for 3 days last week and then for another 2 days this week to Japan from US west coast, two 10-hour roundtrip flights X-<. Now I am back and hopefully fully functional ;-).

*2* The part you quoted in your previous message was this. I am re-quoting from the original to give it a bit more context:

    Two Tree Merge
    ~~~~~~~~~~~~~~
    ...
    In this case, the "git-read-tree -m $H $M" command makes sure
    that no local change is lost as the result of this "merge".
    Here are the "carry forward" rules:
            I (index)           H        M        Result
           -------------------------------------------------------
         ...
            clean I==H  I==M
           ------------------
         ...
         10 yes   yes   N/A     exists   nothing  remove path from cache
This case is covered by this test in t1002:
    test_expect_success \
        '10 - path removed.' \
        'rm -f .git/index &&
         echo rezrov >rezrov &&
         git-update-cache --add rezrov &&
         git-read-tree -m -u $treeH $treeM &&
         git-ls-files --stage >10.out &&
         cmp M.out 10.out &&
         sha1sum -c M.sha1'
Where paths involved are:
	path		treeH		treeM
       -----------------------------------------------------
        bozbar		exists		modified from treeH
        frotz		does not exist	added in treeM
        nitfol		exists		same as in treeH
        rezrov		exists		deleted in treeM

and after this test runs, you can see that the path "rezrov" gets removed from your work tree. Insert "exit" just before the next test, run "cd t && sh t1002-*.sh -i -v", and inspect what is in the "t/trash" directory.

Previous: Daniel BarkalowNext: Joel Becker
Message 84 of 94 in “Updated git HOWTO for kernel hackers”
  1. Jeff GarzikJun 22, 2005
  2. Dave JonesJun 22, 2005
  3. Jeff GarzikJun 22, 2005
  4. Dave JonesJun 22, 2005
  5. Jeff GarzikJun 23, 2005
  6. Jeff GarzikJun 25, 2005
  7. Dave JonesJun 25, 2005
  8. Greg KHJun 22, 2005
  9. Linus TorvaldsJun 22, 2005
  10. Jeff GarzikJun 23, 2005
  11. Linus TorvaldsJun 23, 2005
  12. Jeff GarzikJun 23, 2005
  13. Linus TorvaldsJun 23, 2005
  14. Jeff GarzikJun 23, 2005
  15. Linus TorvaldsJun 23, 2005
  16. Jeff GarzikJun 23, 2005
  17. Linus TorvaldsJun 23, 2005
  18. Jeff GarzikJun 23, 2005
  19. Linus TorvaldsJun 23, 2005
  20. Greg KHJun 23, 2005
  21. Linus TorvaldsJun 23, 2005
  22. Greg KHJun 23, 2005
  23. Jeff GarzikJun 23, 2005
  24. Petr BaudisJun 23, 2005
  25. Martin LanghoffJun 23, 2005
  26. Vojtech PavlikJun 23, 2005
  27. Linus TorvaldsJun 22, 2005
  28. Jeff GarzikJun 23, 2005
  29. Linus TorvaldsJun 23, 2005
  30. Jeff GarzikJun 23, 2005
  31. Linus TorvaldsJun 23, 2005
  32. Linus TorvaldsJun 23, 2005
  33. Jeff GarzikJun 23, 2005
  34. Linus TorvaldsJun 23, 2005
  35. Adam KropelinJun 23, 2005
  36. Linus TorvaldsJun 23, 2005
  37. Jeff GarzikJun 23, 2005
  38. Linus TorvaldsJun 23, 2005
  39. Miles BaderJun 23, 2005
  40. Jeff GarzikJun 23, 2005
  41. Linus TorvaldsJun 23, 2005
  42. Anton AltaparmakovJun 23, 2005
  43. Daniel BarkalowJun 23, 2005
  44. Dave AirlieJun 23, 2005
  45. Mercurial vs Updated git HOWTO for kernel hackersMatt Mackall, Jun 23, 2005
  46. Petr BaudisJun 24, 2005
  47. Christopher LiJun 24, 2005
  48. Petr BaudisJun 28, 2005
  49. Andrew ThompsonJun 28, 2005
  50. Petr BaudisJun 28, 2005
  51. Matt MackallJun 28, 2005
  52. Kyle MoffettJun 28, 2005
  53. SeanJun 28, 2005
  54. Matt MackallJun 28, 2005
  55. SeanJun 28, 2005
  56. Kyle MoffettJun 28, 2005
  57. Matt MackallJun 28, 2005
  58. SeanJun 28, 2005
  59. Kyle MoffettJun 28, 2005
  60. SeanJun 28, 2005
  61. Kyle MoffettJun 29, 2005
  62. SeanJun 29, 2005
  63. Kyle MoffettJun 29, 2005
  64. Vojtech PavlikJun 29, 2005
  65. Matt MackallJun 28, 2005
  66. Thomas Arendsen HeinJun 29, 2005
  67. Andrea ArcangeliJun 24, 2005
  68. Theodore Ts'oJun 24, 2005
  69. Paolo CiarrocchiJun 24, 2005
  70. Christopher LiJun 24, 2005
  71. Kevin SmithJun 24, 2005
  72. Matt MackallJun 24, 2005
  73. Petr BaudisJun 28, 2005
  74. Sven VerdoolaegeJun 28, 2005
  75. Petr BaudisJun 28, 2005
  76. Cygwin and Native MS Windows (was: Mercurial vs Updated git HOWTO for kernel hackers)Kevin Smith, Jun 28, 2005
  77. Cogito vs. Git (was: Mercurial vs Updated git HOWTO for kernel hackers)Kevin Smith, Jun 28, 2005
  78. Petr BaudisJun 28, 2005
  79. Matthias UrlichsJun 24, 2005
  80. Linus TorvaldsJun 24, 2005
  81. John W. LinvilleJun 24, 2005
  82. Jeff GarzikJun 24, 2005
  83. Daniel BarkalowJun 24, 2005
  84. Should "git-read-tree -m -u" delete files?Junio C Hamano, Jun 24, 2005
  85. Joel BeckerJun 24, 2005
  86. Kyle MoffettJun 24, 2005
  87. Pavel MachekJun 27, 2005
  88. Kyle MoffettJun 27, 2005
  89. Matt MackallJun 27, 2005
  90. Benjamin LaHaiseJun 27, 2005
  91. Matt MackallJun 27, 2005
  92. Ed TomlinsonJun 27, 2005
  93. Amin AzezJul 8, 2005
  94. Amin AzezJul 11, 2005

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.