git clone [email protected]:erocarrera/pydot
(35a8d858b)在 Debian 中git config core.autocrlf input
shows:
modified: test/graphs/b545.dot
modified: test/graphs/b993.dot
modified: test/graphs/cairo.dot
这些文件具有 CRLF 行结尾,例如:
$ file test/graphs/cairo.dot
test/graphs/cairo.dot: UTF-8 Unicode text, with CRLF line terminators
The .gitattributes
file contains:
*.py eol=lf
*.dot eol=lf
*.txt eol=lf
*.md eol=lf
*.yml eol=lf
*.png binary
*.ps binary
改变core.autocrlf
对这些文件的状态没有影响。删除.gitattributes
也没有效果。更改这些文件dos2unix
不会改变他们的状态(如预期),并返回unix2dos
与 没有什么区别diff
与较旧的副本相比。文件权限看起来没有变化ls -lsa
。另外,据我所知,这些文件具有统一的行结尾vi -b
(因此不应该是这样的情况unix2dos
or dos2unix
从混合行结尾转换为统一行结尾,这可以解释这种奇怪的行为)。我在用着git
版本 2.11.0。
什么是git
认为有改变吗?
有点相关:
- 即使内容相同,Git 状态也会显示文件已更改
- git clone 之后直接显示为已修改的文件
- 克隆一个 git 存储库,它已经有一个肮脏的工作目录...Whaaaaa?
在多次讨论的搜索过程中,我没有找到解释这种行为的答案。这个问题源于pydot # 163.
更详细地说:
git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test/graphs/b545.dot
modified: test/graphs/b993.dot
modified: test/graphs/cairo.dot
no changes added to commit (use "git add" and/or "git commit -a")
git diff test/graphs/b993.dot
warning: CRLF will be replaced by LF in test/graphs/b993.dot.
The file will have its original line endings in your working directory.
diff --git a/test/graphs/b993.dot b/test/graphs/b993.dot
index e87e112..8aa0872 100644
--- a/test/graphs/b993.dot
+++ b/test/graphs/b993.dot
@@ -1,10 +1,10 @@
-diGraph G{
-graph [charset="utf8"]
-1[label="Umlaut"];
-2[label="ü"];
-3[label="ä"];
-4[label="ö"];
-1->2;
-1->3;
-1->4;
-}
+diGraph G{
+graph [charset="utf8"]
+1[label="Umlaut"];
+2[label="ü"];
+3[label="ä"];
+4[label="ö"];
+1->2;
+1->3;
+1->4;
+}
UPDATE:
出于好奇,我提交了其中一个文件,转储git log -1 -p > diff
, and vi -b diff
表明git
归一化
1 commit 2021d6adc1bc8978fa08d729b3f4d565f9b89651
2 Author:
3 Date:
4
5 DRAFT: experiment to see what changed
6
7 diff --git a/test/graphs/b545.dot b/test/graphs/b545.dot
8 index ebd3e8f..2c33f91 100644
9 --- a/test/graphs/b545.dot
10 +++ b/test/graphs/b545.dot
11 @@ -1,9 +1,9 @@
12 -digraph g {^M
13 -^M
14 -"N11" ^M
15 - [^M
16 - shape = record^M
17 - label = "<p0>WFSt|1571 as Ref: 1338 D"^M
18 -]^M
19 -N11ne -> N11:p0^M
20 -}^M
21 +digraph g {
22 +
23 +"N11"
24 + [
25 + shape = record
26 + label = "<p0>WFSt|1571 as Ref: 1338 D"
27 +]
28 +N11ne -> N11:p0
29 +}
其他奇怪的观察结果:git checkout
克隆后任何这些文件都不会产生任何影响。After上面的提交,文件b545.dot
工作目录中继续有 CLRF 行结尾。正在申请dos2unix
其次是unix2dos
没有做到git
认为它已经改变了(而在提交之前它确实改变了,可能是因为坚定的文件有 CRLF 行结尾)。