Is this possible in any way? I have tried git config --global alias.diff 'diff -b -w'
but unfortunately that was not the solution.
Asked
Active
Viewed 2,362 times
10

prusswan
- 6,853
- 4
- 40
- 61
-
And why wasn't it the solution? (as illustrated by http://stackoverflow.com/questions/2500586/setting-git-default-flags-on-commands). Because setting a flag by default still doesn't seem to be possible: http://stackoverflow.com/questions/1278296/is-there-any-way-to-set-a-flag-by-default-for-a-git-command – VonC Nov 22 '11 at 12:36
-
It did not work, as in it did not affect the behavior of gitk in the way it does the diff. – prusswan Nov 23 '11 at 02:33
-
Ok. I didn't see the "gitk" in the title there. – VonC Nov 23 '11 at 04:54
3 Answers
6
It's a bit old but I found that question the other day googling, and the already accepted answer gave me a hint of how to do it.
No need to modify gitk itself: just edit your .gitk file (~/.config/git/gitk or ~/.gitk) and add:
set ignorespace 1

Vincent Isambart
- 151
- 1
- 2
-
While adding this to `~/.config/git/gitk` has the desired effect on startup, it will be removed again on closing gitk. In `~/.gitk` it has no effect. I guess this only works for options listed as [config_variables](https://github.com/git/git/blob/3e5524907b43337e82a24afbc822078daf7a868f/gitk-git/gitk#L12382). So one would have to add it, as done in [this answer](https://stackoverflow.com/a/35865648/905686). – user905686 Jun 08 '18 at 11:02
5
All that is really required here is to persist the value of the variable set by the checkbutton on the UI. The following patch achieves this. Or you could just force the default to be true at line 11475 (set ignorespace 1
).
From 54f9e800fe28cd6d5d0d44d4e2e561263cbf3407 Mon Sep 17 00:00:00 2001
From: Pat Thoyts <patthoyts@users.sourceforge.net>
Date: Tue, 13 Dec 2011 11:39:01 +0000
Subject: [PATCH] gitk: persist the value of the ignorespace setting for
diffs.
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
gitk-git/gitk | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 2a92e20..29b18d9 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2653,7 +2653,7 @@ proc savestuff {w} {
global cmitmode wrapcomment datetimeformat limitdiffs
global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor
global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
- global hideremotes want_ttk
+ global hideremotes want_ttk ignorespace
if {$stuffsaved} return
if {![winfo viewable .]} return
@@ -2690,6 +2690,7 @@ proc savestuff {w} {
puts $f [list set selectbgcolor $selectbgcolor]
puts $f [list set extdifftool $extdifftool]
puts $f [list set perfile_attrs $perfile_attrs]
+ puts $f [list set ignorespace $ignorespace]
puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(state) [wm state .]"
--
1.7.8.msysgit.0

patthoyts
- 32,320
- 3
- 62
- 93
-
kudos for coming up with a patch for this, but I am unlikely to go to the trouble of custom building of gitk – prusswan Dec 14 '11 at 03:43
-
It is a single file script - you can just edit /usr/local/bin/gitk or wherever it is. – patthoyts Dec 14 '11 at 08:08
-
yes - unless you copy it locally (eg: ~/bin/gitk). The patch could be sumbitted upstream but I suspect most people prefer having this reset each time they close the app. Possibly a decision for the maintainer to make. – patthoyts Dec 14 '11 at 08:23
-
I guess this is probably the best for now. What I do is that I *don't* close the app and just reload it – prusswan Dec 14 '11 at 09:03
-
Except the value will not be preserved over restarts of the application. The `savestuff` function recreates it afresh each time you exit the application so your added line will get removed unless you modify the function as shown. – patthoyts Aug 31 '15 at 14:53
4
Note: Now (after Sept 2014) update gitk config_variables
and add ignorespace
https://github.com/git/git/commit/9fabefb1f3f658e77eb18afa3f95efe1a0ee8d0d
All these are flushed to .gitk
file.

topolik
- 158
- 4
-
1
-
@patthoyts sigh.. but yeah I understood what you are saying, just playing by the "rules" here – prusswan Aug 29 '16 at 06:54