Fossil SCM

Explained why we don't leave diff-command unset for the "bat" alternative.

wyoung 2024-04-26 17:33 trunk
Commit 9fca91e8e3d225f7cf80b3b0226e7e3bc98df2b0918aa196b491a83e611d6da1
1 file changed +7 -1
--- www/colordiff.md
+++ www/colordiff.md
@@ -68,15 +68,21 @@
6868
We can work around the `--color=auto` problem by switching from GNU less
6969
as our pager to [`bat`][bat], as it can detect GNU diff output and
7070
colorize it for you:
7171
7272
fossil set --global diff-command 'diff -dwu --color=auto'
73
- fossil diff -i | bat
73
+ fossil diff | bat
7474
7575
In this author’s experience, that works a lot more reliably than GNU
7676
less’s ANSI color escape code handling, even when you set `LESS=-R` in
7777
your environment.
78
+
79
+The reason we don’t leave the `diff-command` unset in this case is that
80
+Fossil produces additional lines at the start which confuse the diff
81
+format detection in `bat`. Forcing output through an external diff
82
+command solves that. It also means that if you forget to pipe the output
83
+through `bat`, you still get colorized output from GNU diff.
7884
7985
[bat]: https://github.com/sharkdp/bat
8086
8187
8288
<a id="colordiff"></a>
8389
--- www/colordiff.md
+++ www/colordiff.md
@@ -68,15 +68,21 @@
68 We can work around the `--color=auto` problem by switching from GNU less
69 as our pager to [`bat`][bat], as it can detect GNU diff output and
70 colorize it for you:
71
72 fossil set --global diff-command 'diff -dwu --color=auto'
73 fossil diff -i | bat
74
75 In this author’s experience, that works a lot more reliably than GNU
76 less’s ANSI color escape code handling, even when you set `LESS=-R` in
77 your environment.
 
 
 
 
 
 
78
79 [bat]: https://github.com/sharkdp/bat
80
81
82 <a id="colordiff"></a>
83
--- www/colordiff.md
+++ www/colordiff.md
@@ -68,15 +68,21 @@
68 We can work around the `--color=auto` problem by switching from GNU less
69 as our pager to [`bat`][bat], as it can detect GNU diff output and
70 colorize it for you:
71
72 fossil set --global diff-command 'diff -dwu --color=auto'
73 fossil diff | bat
74
75 In this author’s experience, that works a lot more reliably than GNU
76 less’s ANSI color escape code handling, even when you set `LESS=-R` in
77 your environment.
78
79 The reason we don’t leave the `diff-command` unset in this case is that
80 Fossil produces additional lines at the start which confuse the diff
81 format detection in `bat`. Forcing output through an external diff
82 command solves that. It also means that if you forget to pipe the output
83 through `bat`, you still get colorized output from GNU diff.
84
85 [bat]: https://github.com/sharkdp/bat
86
87
88 <a id="colordiff"></a>
89

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button