Re: [BUG] Move tracking in git diff is not as good as in git status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 4, 2015, at 22:11, Scott Schmit wrote:

In my use of git, I've noticed that "git status" is a lot better at
tracking moves and renames than "git diff", and this has recently caused
me a lot of headaches because a large number of moves were made in a
single commit, and it was very difficult to figure out which moves were
right and which were wrong.

I was using a fairly old version of git (1.7.11), but was able to
reproduce it on git 2.2.1.

Here's a reproduction recipe:
[...]
# Now "shift" the files
git mv 2 3
git mv 1 2
[...]
git commit -m "2=1;3=2;"

# Neither of these commands get it (but -C gets a glimmer of the truth)
git diff -M --stat --summary HEAD~..
git diff -C --stat --summary HEAD~..

Ah, but did you try this:

  git diff -B -M --stat --summary HEAD~..

# Swap the files in place
git mv 3 tmp
git mv 2 3
git mv tmp 2
[...]
git commit -m "Swap 2 & 3"

# Diff has no idea
git diff -M --stat --summary HEAD~..
git diff -C --stat --summary HEAD~..

Again, try this:

  git diff -B -M --stat --summary HEAD~..

You can even use this:

  git log -B -M --summary

to see them all.

While you can configure -M (or -C) to be on by default (see git config diff.renames), there does not appear to be a config option to turn on - B (--break-rewrites) by default.

And according to a recent thread [1], using -B and -M together can produce incorrect results so you might not want them both on by default anyway.

-Kyle

[1] http://thread.gmane.org/gmane.linux.kernel/1879635
--
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]