ike3
ike3

Reputation: 1800

Git diff shows files with no changes

I am trying to make a diff between local and remote git branches using the following command:

git diff --ignore-space-at-eol -b -w --minimal remotes/branch/master > diff.patch

Everything is ok except I see in the patch file output such as

diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp
index a271c8a..6f363c6 100644
--- a/src/game/AccountMgr.cpp
+++ b/src/game/AccountMgr.cpp
diff --git a/src/game/AccountMgr.h b/src/game/AccountMgr.h
index d406496..405fa32 100644
--- a/src/game/AccountMgr.h
+++ b/src/game/AccountMgr.h
...

Seems there are no changes in such files. How can I remove such files from the diff?

Upvotes: 3

Views: 788

Answers (2)

VonC
VonC

Reputation: 1323075

Note that the same git diff --ignore-space-at-eol can have the reverse bug: show no change where there is one:

See commit 044fb19, commit a5229cc (09 Jul 2016) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit f2cfb8f, 25 Jul 2016)

git version
git version 2.9.2.windows.1

printf "a\nb\nc\n" >pre
printf "a\nbX\nc\n" >post
git diff --no-index --patience --ignore-space-at-eol pre post
(empty!?)

Git 2.10+ (Q3 2016) will fix that:

diff: fix a double off-by-one with --ignore-space-at-eol

When comparing two lines, ignoring any whitespace at the end, we first try to match as many bytes as possible and break out of the loop only upon mismatch, to let the remainder be handled by the code shared with the other whitespace-ignoring code paths.

When comparing the bytes, however, we incremented the counters always, even if the bytes did not match.
And because we fall through to the space-at-eol handling at that point, it is as if that mismatch never happened.

See "xdiff/xutils.c"

Upvotes: 1

ike3
ike3

Reputation: 1800

Seems a bug in an outdated msys git version. Update to the latest fixed the problem.

Upvotes: 0

Related Questions