【发布时间】:2020-04-29 07:59:33
【问题描述】:
在我维护的代码中,我有时会收到提交者无缘无故重排段落的拉取请求。这是一个例子:
diff --git a/knuth.tex b/knuth.tex
index 2f6a2f8..7b0827d 100644
--- a/knuth.tex
+++ b/knuth.tex
@@ -1,6 +1,6 @@
Thus, I came to the conclusion that the designer of a new
system must not only be the implementer and first
-large||scale user; the designer should also write the first
+large-scale user; the designer should also write the first
user manual.
The separation of any of these four components would have
@@ -9,8 +9,7 @@ all these activities, literally hundreds of improvements
would never have been made, because I would never have
thought of them or perceived why they were important.
-But a system cannot be successful if it is too strongly
-influenced by a single person. Once the initial design is
-complete and fairly robust, the real test begins as people
-with many different viewpoints undertake their own
-experiments.
+But a system cannot be successful if it is too strongly influenced by
+a single person. Once the initial design is complete and fairly
+robust, the real test begins as people with many different viewpoints
+undertake their own experiments.
如您所见,第一个大块引入了实际更改,将 || 替换为 -,而第二个大块除了换行和空格之外没有任何变化。事实上,第二个大块的word-diff 是空的。
是否可以制定一个政策(例如在 GitHub 或我的 CI 中)拒绝包含此类“空”大块的提交,或者重新格式化补丁以完全忽略这些大块,以便我可以 git apply 它而不他们?
【问题讨论】:
-
您的问题似乎是关于 GitHub,而不是关于 Git。我建议使用那个标签(也许没有当前的标签)。
-
@torek 该策略不一定必须在 GitHub 上。我也可以在我的 CI 中强制执行它。所以我把GitHub放在括号里。
-
您是否尝试过更改 core.eol 或 core.safecrlf 或 core.autocrlf 来处理线路断路器问题?这就是你要找的:stackoverflow.com/questions/3515597/…?
-
@YazeedSabri 感谢您指出这一点,但不,您链接的问题不涉及重排文本。
-
@HenriMenke 您可能想尝试将此选项“--word-diff”添加到 diff 命令以处理文本重排。
标签: git diff whitespace patch