Subject: Re: Suggested workflow for frequent directory renames.

From: Jakub Narebski <[email-masked]>
Date: Tue, 26 May 2009 02:24:16 -0700 (PDT)

Matthew Clemence <[email-masked]> writes:

> I am working with an externally supplied code tree (some 2000 files,
> which gets passed to me without any SCM) and have multiple users
> working on their own individual branched versions under git
> control. The problem I am facing is that there are frequenct directory
> renames when the code updates which I need to find a relatively
> painless way of bringing the users branches up to date. 

Hmmm... are you sure you are solving the correct problem? Can't you
avoid directory renames, e.g. by munging position of files before
entering them into SCM?

> From reading
> the lists and faq, there seems to be problems (and strong opinions)
> with this, and I am struggling to find an effcient model to manage
> this merging - either git loses track of the users changed files (and
> so have to be manually merged from diff files and usually lose
> history) or git loses track of everything else (and I end up manually
> adding files from the new tree to get out of merge conflict).
> 
> I would be very interested to hear if anyone has a suggestion on how
> this could best be handled.

Git, contrary to other version control systems such as Mercurial or
Bazaar, doesn't use tracking of renames (either via recording rename
event, or by using file identities / inodes), but heuristic similarity
based rename _detection_.  If the files are of sufficient size
compared to changes, rename detection should work well and when
merging changes should be applied to correct files / correct files
would be renamed.  Changing directory the file resides in is currently
in Git just the form of changing pathname of a file, i.e. renaming of
a file.  Rename detection uses similarity of filename as one of
factors so if basename didn't change git should correctly pair files.

The problem currently is when one side renames directory, and other
side creates new file in the old-name directory.  Rename tracking
would not help here unless SCM track also directory renames, like
Bazaar reportedly does.

But the problem is not impossible to overcome using rename detection
like in git.  There were even patches adding detection of wholesame
directory renaming (factoring out directory renames out of set of
detected file renames) by Yann Dirson, but they were not accepted for
some reason.  You migh want to either contact author, or clean up the
series and send them yourself (if possibly with use cases and success
stories):
  http://thread.gmane.org/gmane.comp.version-control.git/99529

See also directory rename detection script (in Perl) in
  http://permalink.gmane.org/gmane.comp.version-control.git/81547

BTW. This issue was discussed extensively on git mailing list...
-- 
Jakub Narebski
Poland