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

Re: Comments on "Understanding Version Control" by Eric S. Raymond

From
Theodore Tso <tytso@mit.edu>
Date
Feb 5, 2009, 02:43 UTC
Message-ID
<20090205024333.GH8945@mit.edu>
In-Reply-To
<7v4oz9lpes.fsf@gitster.siamese.dyndns.org>
On Wed, Feb 04, 2009 at 04:04:43PM -0800, Junio C Hamano wrote:
Show 21 quoted lines
> Theodore Tso <tytso@mit.edu> writes:
> 
> > 1) In branch A, the directory src/plugin/innodb-experimental is
> >    renamed to src/plugin/innodb, and in branch B, a commit (i)
> >    modifies a file src/plugin/innodb-experimental/table.c, and (ii)
> >    creates a file src/plugin/innodb-experimental/mod-schema.c.  This
> >    commit in branch B is then pulled into branch A, where the
> >    directory rename has taken place.  The user may not know that a
> >    directory rename had taken place under the covers, so they don't
> >    give any magic options when they run the "git cherry-pick" or "git
> >    merge" command.  Does the right thing happen such that the right
> >    file in src/plugin/innodb is modified, and the new file is created
> >    in src/plugin/innodb, even though in the original commit, the
> >    changes were made to files in src/plugin/innodb-experimental?
> 
> Careful.
> 
> Although it is reasonable to expect that existing file's modification will
> move to innodb/ directory, it is not as clear-cut as some people seem to
> assume that the new file should always be created in the new directory
> innodb/.

Careful; that's actually an argument for recording the directory rename. If the intention is to rename the directory containing some plugin, where all of the associated files are for the plugin foobar, and we are renaming the directory because plugin has had its name changed to fooblatz, then a commit which introduces a new file, say table.c probably does want to get created in the new directory --- especially if one of the changes was to foobar/Makefile:

--- Makefile.in 2009-02-04 21:28:43.977052347 -0500 +++ Makefile.in.orig 2009-02-04 21:28:38.830212569 -0500

@@ -60,7 +60,7 @@
 #
 #MCHECK= -DMCHECK
 
-OBJS= table.o crc32.o dict.o unix.o pass1.o pass1b.o pass2.o \
+OBJS= crc32.o dict.o unix.o pass1.o pass1b.o pass2.o \
       pass3.o pass4.o pass5.o journal.o badblocks.o util.o dirinfo.o \
       dx_dirinfo.o ehandler.o problem.o message.o recovery.o region.o
 
In other cases, maybe the right thing *is* to drop the new file in the
original directory.  So as the Hg and Bzr apologists might say, if the
SCM actually records whether the user intention was a *directory*
rename, versus a series of *file* rename/moves, then it becomes
obvious what the right thing to do.

But if the SCM is tracking *content* as git does, then we don't have
the benefit of having recorded the user's intention, so we have to use
hueristics.  We can say that if *all* of the files in the directory
foobar had been moved to fooblatz as part of a commit, it's likely
that new commits that create new files in foobar should create them in
fooblatz --- especially if the new file name is mentioned in a file
named "Makefile" or "Makefile.in".  Or we can give up and ask the user
what was intended at merge time.  That's admittedly as annoying as
throwing up the Annoying Dialog Box at commit time when folding in a
patch (which is how systems that record user intention have to do
things).  Ultimately, there are only three choices; either the user
tells the SCM, the SCM asks the user, or the SCM applies some
hueristic (i.e., the SCM "guesses").  This can happen at commit time
or it can happen at merge time, but and in some cases the SCM can use
a combination of techniques depending on whether a patch is being
imported or whether the user is explicitly telling the scm via "scm
mv", "scm mvdir", "scm cp", et. al.

But if we throw up our hands and say, it's impossible to guess
correctly, then that leaves us open to the argument from people from
the Hg or Bzr camp to say, "You see, tracking *content* is really for
the birds; you really have to let/force the user to *tell you* and
record the whether the directory is being moved, or a series of files
in the directory are being moved."

Instead, I would argue that just as we've shown that while collisions
can happen, the costs of locking files ala RCS outweigh the costs, it
also is better to use hueristics to determine whether a file should be
created in the original directory or the apparently renamed directory
location, and then let the user fix things up afterwards if the
algorithm gets it wrong.  If the corner case only happens 1% of the
time, and our algorithm gets it right 99% of the time, the resulting
0.01% error rate is probably quite acceptable.

      	  	    	  	     		 - Ted
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 21 in “Comments on "Understanding Version Control" by Eric S. Raymond”
  1. Jakub NarebskiFeb 2, 2009
  2. Theodore TsoFeb 2, 2009
  3. Eric S. RaymondFeb 2, 2009
  4. Jakub NarebskiFeb 3, 2009
  5. Jakub NarebskiFeb 4, 2009
  6. Theodore TsoFeb 4, 2009
  7. Junio C HamanoFeb 5, 2009
  8. Theodore TsoFeb 5, 2009
  9. Junio C HamanoFeb 5, 2009
  10. Theodore TsoFeb 5, 2009
  11. Junio C HamanoFeb 5, 2009
  12. Jakub NarebskiFeb 5, 2009
  13. Theodore TsoFeb 5, 2009
  14. Miles BaderFeb 5, 2009
  15. Eric S. RaymondFeb 5, 2009
  16. Jakub NarebskiFeb 5, 2009
  17. Theodore TsoFeb 5, 2009
  18. Jakub NarebskiFeb 5, 2009
  19. Theodore TsoFeb 5, 2009
  20. Tests for "Understanding Version Control" by Eric S. RaymondJakub Narebski, Feb 4, 2009
  21. Jakub NarebskiFeb 10, 2009

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.