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

Re: [PATCHv2] git-mv: Keep moved index entries inact

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 28, 2008, 18:24 UTC
Message-ID
<alpine.DEB.1.00.0807281919400.8986@racer>
In-Reply-To
<alpine.DEB.1.00.0807281610270.8986@racer>
Hi,
On Mon, 28 Jul 2008, Johannes Schindelin wrote:
Show 27 quoted lines
> On Mon, 28 Jul 2008, Johannes Schindelin wrote:
> 
> > On Mon, 28 Jul 2008, SZEDER Gábor wrote:
> > 
> > > there is a race somewhere in these 'git-mv: Keep moved index entries 
> > > inact' changes.
> > > 
> > > The test cases 'git mv should overwrite symlink to a file' or 'git 
> > > mv should overwrite file with a symlink' fail occasionaly.  It's 
> > > quite non-deterministic:  I have run t7001-mv.sh in a loop (see 
> > > below) and one or the other usually fails around 50 runs (but 
> > > sometimes only after 150).  Adding some tracing echos to the tests 
> > > shows that both tests fail when running 'git diff-files' at the end.
> > 
> > To make it more convenient to test: with this patch it fails all the 
> > time:
> 
> Ooops.  Seems like I changed the test 23 to fail, instead of test 24.  
> However, I think it is the same bug: the index is newer by one second, 
> so it seems that the patch for builtin-mv.c did not really keep the data 
> "intact".
> 
> Note that a test case should use test-chmtime to force this scenario, 
> not sleep a second.
> 
> Unfortunately, I already spent my Git time budget for today, so the ball 
> is out of my half for now.
Hah!  I had a few minutes, and this is my analysis:

Just try to "mv" a file, and look at the _ctime_ before and after. Yes, that is right, at least on my system (ext3) it _changes_.

So the test 23 and 24 in t7001-mv.sh are totally bogus. They purport to test that git-mv retains the whole meta-information in the cache and therefore the index does not need to be updated.

However, it _does_ need to be updated, exactly because ctime changed.

Only that the test failed to test what it tried to test, instead succeeding erroneously, just because the index was racy most of the time and got silently updated.

So, this is the analysis. The fixes will have to be done by somebody else, because /me goes running now.

(Possible fixes I envisage: update ctime via stat() after rename(), or just give up and scrap the whole "leave cache_entry inact" thing.)

Ciao, Dscho

Previous: Johannes SchindelinNext: Junio C Hamano
Message 23 of 56 in “Submodule support in git mv, git rm”
  1. Petr BaudisJul 16, 2008
  2. 1/7 git-mv: Remove dead code branchPetr Baudis, Jul 16, 2008
  3. 2/7 t7400: Add short "git submodule add" testsuitePetr Baudis, Jul 16, 2008
  4. 3/7 git submodule add: Fix naming clash handlingPetr Baudis, Jul 16, 2008
  5. 4/7 submodule.*: Introduce simple C interface for submodule lookup by pathPetr Baudis, Jul 16, 2008
  6. 5/7 git mv: Support moving submodulesPetr Baudis, Jul 16, 2008
  7. Junio C HamanoJul 17, 2008
  8. Petr BaudisJul 17, 2008
  9. git-mv: Keep moved index entries inactPetr Baudis, Jul 17, 2008
  10. git mv: Support moving submodulesPetr Baudis, Jul 17, 2008
  11. Junio C HamanoJul 19, 2008
  12. Petr BaudisJul 21, 2008
  13. [PATCHv2] git-mv: Keep moved index entries inactPetr Baudis, Jul 21, 2008
  14. Junio C HamanoJul 21, 2008
  15. Junio C HamanoJul 26, 2008
  16. Petr BaudisJul 27, 2008
  17. t/t7001-mv.sh: Propose ability to use git-mv on conflicting entriesPetr Baudis, Jul 27, 2008
  18. Junio C HamanoJul 28, 2008
  19. Junio C HamanoJul 28, 2008
  20. SZEDER GáborJul 28, 2008
  21. Johannes SchindelinJul 28, 2008
  22. Johannes SchindelinJul 28, 2008
  23. Johannes SchindelinJul 28, 2008
  24. Junio C HamanoJul 28, 2008
  25. Johannes SchindelinJul 28, 2008
  26. Johannes SchindelinJul 28, 2008
  27. Petr BaudisJul 29, 2008
  28. Junio C HamanoJul 29, 2008
  29. Junio C HamanoJul 29, 2008
  30. Not going beyond symbolic linksJunio C Hamano, Aug 4, 2008
  31. 1/2 update-index: refuse to add working tree items beyond symlinksJunio C Hamano, Aug 4, 2008
  32. 2/2 add: refuse to add working tree items beyond symlinksJunio C Hamano, Aug 4, 2008
  33. Linus TorvaldsAug 5, 2008
  34. Junio C HamanoAug 5, 2008
  35. Linus TorvaldsAug 5, 2008
  36. Johannes SchindelinAug 5, 2008
  37. Linus TorvaldsAug 5, 2008
  38. Junio C HamanoAug 5, 2008
  39. Dmitry PotapovAug 5, 2008
  40. Junio C HamanoAug 5, 2008
  41. Linus TorvaldsAug 5, 2008
  42. Junio C HamanoAug 5, 2008
  43. Johannes SchindelinAug 5, 2008
  44. Junio C HamanoAug 5, 2008
  45. david@lang.hmAug 5, 2008
  46. Junio C HamanoAug 7, 2008
  47. Junio C HamanoAug 8, 2008
  48. Linus TorvaldsAug 8, 2008
  49. Johannes SchindelinJul 21, 2008
  50. Petr BaudisJul 21, 2008
  51. Junio C HamanoJul 21, 2008
  52. 6/7 git rm: Support for removing submodulesPetr Baudis, Jul 16, 2008
  53. Johannes SchindelinJul 16, 2008
  54. Petr BaudisJul 17, 2008
  55. Johannes SchindelinJul 17, 2008
  56. 7/7 t7403: Submodule git mv, git rm testsuitePetr Baudis, Jul 16, 2008

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.