On Wed, May 10, 2017 at 02:15:23PM -0500, Samuel Lijin wrote:

> On Wed, May 10, 2017 at 9:46 AM, Jonny Gilchrist
> <jonnygilchr...@gmail.com> wrote:
> > Hi,
> >
> > After doing a subtree merge, using 'git log' and 'git log --follow' on
> > files in the subtree show only the merge commit in which they were
> > added.
> >
> > After reading around I understand that the issue is that git log
> > --follow doesn't track renames that occur during a merge.
> 
> Try git log --follow -M. (You may also want to combine this with -l and/or 
> -C).
> 
> > Has there been any work (or are there any plans) to allow git log
> > --follow to work in this case? I couldn't find anything in the mailing
> > list archives aside from a couple of threads from 2011 explaining the
> > issue.

Please note that technicaly there wasn't any "rename during merging":
the subtree merge took the three object of the tip commit you were
merging and recorded in in the merge commit as appearing under another
tree object -- identifying the directory which was used as the subtree
prefix.  The result is that the merge commit and the commits recorded
after it have the files of the merged-in history under that prefix, but
the merged-in history itself has them "as is".

Since Git does not record renames (that is, the `git mv` command does
not record a rename either -- the file it "moves" merely "reappears" in
the next commit under a different name), there are two solutions to your
problem.  The first one is to use the usual heuristics of rename/copy
detection at the time of the history traversal -- as suggested by
Samuel.

The second one -- if you don't need the merged-in history to be kept
"pristine" -- is to first run a `git filter-branch` command on it to
relocate the files in all the reachable commits it contains under the
same prefix which you have used for subtree merge and then do that
subtree merge.

Of course, that only works if that history is "yours" and the merging is
considered to be a one-off operation (that is, you won't be updating the
original merged-in line of development).

Reply via email to