I did some research.
The configuration core.whitespace
has nothing to do with how tabs are displayed. It is only used for git to recognize tab related whitespace errors. For example: when indent-with-non-tab
is enabled, and core.whitespace
is set to tabwidth=4
, and a line is indented using 4 spaces or more, then git will report an error.
For git, apart from the tab related whitespace error detection features, a tab character is a character like any other character. It gets compared and it gets dumped to whatever tool is used to display the characters. That means, to configure the displayed tab width you have to configure the "front ends" of git. In case of git diff
that would be "less" (the unix tool "less"). In case of git gui
that would be git-gui itself.
Configuring less is easy. You can set the git configuration core.pager
to setup less to display a tab using 4 spaces (less has a parameter -xn
to set tabwidth to n
).
Configuring git-gui turned out to be considerably harder. Git-gui is written in Tcl/Tk. I found a Tcl/Tk option to configure the tab width in text widgets. I also found a line in git-gui.sh
where it looks like the text widget is being initialized.
This is line 3346 of the file git-gui.sh
in git version 1.7.5:
catch {$ui_diff configure -tabstyle wordprocessor}
I changed that, according the Tcl/Tk manual, to:
catch {$ui_diff configure -tabs "[expr {4 * [font measure $font 0]}]" -tabstyle wordprocessor}
That did not seem to have any effect. I tried different values for -tabs
and they did have some effect on displayed tab width, so it seems to be the correct line to modify.
Unfortunately, Tcl/Tk does not seem to have a notion of tab width in terms of characters, instead, the tab width has to be set in pixels or centimeters.
Note that I have no experience in Tcl/TK whatsoever, so maybe I am just overlooking something simple here.
Anyway, now you know where to start digging. Remember to report back here if you have a working solution. Good luck.