0

The output of git diff says that the complete contents of one my files has been removed, and then added back. Why is this?

diff --git a/templates/appengine/go/app.yaml b/templates/appengine/go/app.yaml
index 303af12..223b642 100644
--- a/templates/appengine/go/app.yaml
+++ b/templates/appengine/go/app.yaml
@@ -1,13 +1,13 @@
-# Right now, we direct all URL requests to the Go app we are about to
-# construct, but in the future we may add support for jQuery and Bootstrap
-# to automatically put a nice UI on the / url.
-
-application: {{ app_id.downcase }}
-version: 1
-runtime: go
-api_version: 3
-
-handlers:
-- url: /.*
-  script: _go_app
-
+# Right now, we direct all URL requests to the Go app we are about to
+# construct, but in the future we may add support for jQuery and Bootstrap
+# to automatically put a nice UI on the / url.
+
+application: {{ app_id.downcase }}
+version: 1
+runtime: go
+api_version: 3
+
+handlers:
+- url: /.*
+  script: _go_app
+
Andres Riofrio
  • 9,851
  • 7
  • 40
  • 60

2 Answers2

2

This kind of git diff output is expected if you have converted the line endings (e.g. by using a badly behaving editor running in Windows with Unix style line endings to begin with resulting to LF -> CR LF conversion). This is typical way to change every line of a file without other than white space changes, which you typically cannot decipher from the raw diff output to terminal.

Option -w for git diff will make git diff ignore white space changes. What will git diff -w look like in your case? If it shows no changes, then the white spaces are the reason for your output.

In such a case, you could do git diff | tr '\r' '~' to see the CR characters changed to '~' characters in the git diff output (assuming Unix tools available).

FooF
  • 4,323
  • 2
  • 31
  • 47
0

It shows it because it was removed in one commit and then added back in. So the difference between the current state and the last commit has changed.

tpg2114
  • 14,112
  • 6
  • 42
  • 57
  • This does not seem to be true by quick test (git version 1.7.5.4). Test procedure: `mkdir test; cd test; git init; cp /etc/passwd .; git add passwd; git commit -m 'add passwd'; git rm passwd; git commit -m 'remove passwd'; cp /etc/passwd .; git add passwd; git commit -m 'add passwd again'` The result of `git diff HEAD^^` is empty. – FooF May 24 '12 at 07:48