From: Shawn O. Pearce Date: Tue, 06 May 2008 02:12:02 GMT Subject: Re: merge renamed files/directories? Message-ID: <20080506021202.GN29038@spearce.org> In-Reply-To: <32541b130805051858u7b8f1cd7qd34fdf50c1f849d0@mail.gmail.com> Avery Pennarun wrote: > On 5/5/08, Shawn O. Pearce wrote: > > > > `git pull -s subtree mylib` ? > > First, I thought: wow! How can that possibly work? These guys are geniuses! > > Then I found out that git-merge-subtree is a git builtin, and git.c says this: > > { "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE }, > { "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE }, > > And then my head exploded. :) > > Still scraping the pieces of my brain back off the floor... but does > this mean the subtree merge strategy would fail exactly like > merge-recursive when new files are created? Nope. If you go look at cmd_merge_recursive you will see it has different behavior based upon the name it was invoked as, even though it is the same C function and has the same implementation. If it is started with the name "merge-subtree" it tries to find a matching subtree prefix to insert in front of all names, or to remove from all names, such that a merge will correctly fully include a set of files in a subdirectory, or full pull out a set of files from a subdirectory. Junio is the genius that implemented this. Works quite well for this library->application merge case that I think you were trying to describe. -- Shawn.