Skip to content

Commit bc5ca5a

Browse files
committed
doc: clarify that --word-diff operates on line-level hunks
The --word-diff documentation describes the output modes and word-regex mechanics but does not explain that word-diff operates within the hunks produced by the line-level diff rather than performing an independent word-stream comparison. This can surprise users when the line-level alignment causes word-level changes to appear even though the words in both files are identical. Add an implementation note explaining the two-stage relationship and that the output may change if Git acquires a different implementation in the future. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
1 parent 94f0577 commit bc5ca5a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Documentation/diff-options.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,14 @@ endif::git-diff[]
457457
+
458458
Note that despite the name of the first mode, color is used to
459459
highlight the changed parts in all modes if enabled.
460+
+
461+
The `--word-diff` option operates by taking the same line-by-line
462+
diff that is produced without the option and computing
463+
word-by-word changes within each hunk. This may produce a
464+
larger diff than a dedicated word-diff tool would. If Git
465+
acquires a different implementation in the future, the output
466+
may change. Note that this is similar to the `--diff-algorithm`
467+
option, which may also change the output.
460468

461469
`--word-diff-regex=<regex>`::
462470
Use _<regex>_ to decide what a word is, instead of considering

0 commit comments

Comments
 (0)