From: "Dale R. Worley" <wor...@alum.mit.edu> Sent: Wednesday, December 12, 2012 5:46 PM
From: "Philip Oakley" <philipoak...@iee.org>

> OK, so it seems that when you move files around, and then tell git > to
> notice that, git will automagically figure out what the moves were.
> The O'Reilly book wasn't clear on that. (Nor did it explain how > git
> can distinguish a move from file that just happens to have the same
> contents.)

Actually git does not even attempt to record the movements themselves.
There is a strongly worded post by Linus Torvalds all about why he
*believes* it is the Right Thing (tm) to do.

The key being that git is a *content* tracker, not a file tracker, and if you commit often the changes are small, so it is easy to infer where
the changes came from and went to.

Let me see if I understand this:  Git only connects the "before" and
"after" locations of a file by the fact that they have the same (or
very similar) contents.

Yes. It works well. It can also detect the movement of code chunks as well.

How, then, do merges handle this information?  If the "delta" is that
./a/123 was moved into ./b/456, does the merging process understand
that, and move the same file in the destination directory?  Or does it
only do so if ./a/123 in the destination directory is similar enough
to ./a/123 in the delta?

Git doesn't do deltas. It does complete snapshots.

It is only when it is doing internal compression that any delta packing compression occurs, and it doesn't restrict itself to previous version of the same file. It will use any similar file (so spotting renames, duplicate copies, hack and hope coding, etc).

Merging is done filename by filename (you specifically add files by name and location in the directory tree).

By making branching easy and commits easy and local, the merging is in general almost automatic - distinct line changes slot into the merged file without conflict for the slot. Auto-merging won't spot other structural changes such as changing a function definition - you still need a developer with brains in such cases!


Similarly, if the delta is a particular change in file A, if in the
destination directory there is a very similar file B, will merging
change B?  What if there are multiple files in the destination
directory with similar contents; might they all be changed?

A and B won't be merged as they don't have the same name nor location.


If there are multiple files in a tree with identical contents (say,
all zero-length), does Git confuse changes in one with changes in the
others?

One of the corner cases for zero length files was cleared up recently, so in general 'no', git doesn't get confused (anymore than we humans confuse ourselves ;-)


Dale

--

--


Reply via email to