Git diff文件名打破一致性

Ale*_*spo 0 git diff filenames git-diff

该行取自原始差异,包括2852个文件更改(切换多个库).

diff --git "a/system/cms/config/database.php\n" "b/system/cms/config/database.php\n"
Run Code Online (Sandbox Code Playgroud)

在所有2852个文件更改中,这是唯一的差异,其中文件名用引号括起来并以"\n"结尾.每个其他相关的行都符合这种模式.

diff --git a/system/cms/config/constants.php b/system/cms/config/constants.php
Run Code Online (Sandbox Code Playgroud)

知道为什么会这样吗?

Mat*_*Mat 5

发生这种情况是因为您实际上有一个文件名,\n其末尾包含一个.

$ 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
Run Code Online (Sandbox Code Playgroud)