In a code I am maintaining, I sometimes receive pull requests where the committer just reflowed a paragraph for no apparent reason. Here is an example:
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.
As you can see the first hunk introduced an actual change by substituting ||
with -
, whereas the second hunk does not change anything but line breaking and whitespace. In fact, the word-diff
of the second hunk would be empty.
Is it possible to either put a policy in place (e.g. on GitHub or in my CI) to reject commits containing such “empty” hunks, or reformat the patch to omit these hunks altogether so that I can git apply
it without them?
Related: How to git-apply a git word diff