2011/8/22 Michael Witten <mfwitten@xxxxxxxxx>: > I assume the smiley is tongue-in-cheek; however, in case it is not: It > can't be automatic in general; did my examples mean nothing? > >> Or at least detect/warn about tree conflict. > > Did my examples mean nothing? Well kind of. Your example was different because you have created dir1 independently on branch1 and master in which case automatic rename wouldn't be expected. If you would've created dir1 before branching and renamed dir1 to dir3 (renamed all files under dir1) then I would expect a rename while merging. The exact behaviour of merging branch1 to master I want is: let base = $(git merge-base master branch1) for each {modified,added,deleted} file in $base..branch1: let dir = $(dirname $file) if $dir exists in master: if $dir existed in $base: [1] proceed else: # both branches independently introduced same directory tree conflict else: # no $dir in master if $dir existed in $base: if all $dir/* files in $base..master were renamed to $newdir/*: rename $file [s/$dir/$newdir/] else: # $dir was removed tree conflict else: proceed # simple addition Where "$dir exists" means that a file with path of matching prefix exists. By default tree conflict should be ignored (proceed with merge as today) but user should be able to make it fatal. [1] It would be better if instead of comparing two trees it would analyze each commit independently to detect shadowed renames: (dir1=>dir2 then new dir1) => still rename. > >> Directory renames can happen quite frequently when working with Java/C# >> and it is unreasonable to expect that lazy user will have to keep track of >> it manually (with huge number of files it's impossible). > > Git doesn't know anything about Java/C#; that's the point. And it shouldn't. Renames can happen with anything, I'm just pointing out that they are quite frequent in Java/C#. You might as well have a C project and rename directory "src" to "sources" and, when merging branch created from before that, expect to get automatic s/src/sources/. > In general, the user could make use of switches (as suggested). In > particular, perhaps there are merge hooks or merge drivers that could > be used or implemented for allowing a more environment-specific > handling of merges, a la GNU's ChangeLog merge driver: > Also, see the configuration section of `git help merge'. Also look at > the tool `git mergetool'. > Merge drivers are file type specific, mergetool is used to resolve conflicts after merge and I don't see a pre-merge hook :( -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html