# Suggested workflow for frequent directory renames.

2 messages from 2009-05-26 to 2009-05-26. Participants: Matthew Clemence, Jakub Narebski.
Thread: https://gitlist.dev/t/19507

## Matthew Clemence, 2009-05-26 00:17

Subject: Suggested workflow for frequent directory renames.
Message-ID: <4A1B352C.9030409@virgin.net>
URL: https://gitlist.dev/e/4A1B352C.9030409%40virgin.net

```
Dear git users,

I am working with an externally supplied code tree (some 2000 files, 
which gets passed to me without any SCM) and have multiple users wokring 
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. 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.

Many thanks

Matthew

```

## Jakub Narebski, 2009-05-26 09:24

Subject: Re: Suggested workflow for frequent directory renames.
Message-ID: <m37i04cj45.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m37i04cj45.fsf%40localhost.localdomain
In-Reply-To: <4A1B352C.9030409@virgin.net>

```
Matthew Clemence <matthew.clemence@virgin.net> 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

```
