Alex Naspo
Alex Naspo

Reputation: 2102

Git diff filenames breaking consistency

This line was taken from a raw diff consisting of 2852 file changes (switched multiple libraries).

diff --git "a/system/cms/config/database.php\n" "b/system/cms/config/database.php\n"

Out of all 2852 file changes, this is the only diff in which the filenames are enclosed in quotes and terminated with "\n". Every other related line fits this pattern.

diff --git a/system/cms/config/constants.php b/system/cms/config/constants.php

Any idea as to why this is happening?

Upvotes: 0

Views: 88

Answers (1)

Mat
Mat

Reputation: 206859

This is happening because you actually have a filename that contains a \n at the end of it.

$ git init
Initialized empty Git repository in /home/foo/tmp/.git/
$ echo foo > a$'\n'
$ git add a*
$ git commit -m one
[master (root-commit) 2ce40fd] one
 1 file changed, 1 insertion(+)
 create mode 100644 "a\n"
$ echo bar >> a*
$ git diff|less
diff --git "a/a\n" "b/a\n"
index 257cc56..3bd1f0e 100644
--- "a/a\n"
+++ "b/a\n"
@@ -1 +1,2 @@
 foo
+bar

Upvotes: 5

Related Questions