git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?
PATCH 1/1 git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?
Home of the original description and the author of the patch:
http://www.spinics.net/lists/git/msg174415.html
Why not added this useful little patch for git-gui ?
( this patch resolve my problem with 8 spaces tab Linux Eclipse + Java program source + git gui and I apply locally it to each new version git before source compilation )
original content of the message from the link above:
----------------------
For Tk 8.5 the "wordprocessor" mode allows us to get a bit fancy for merge diffs and intend the tabs by one to compensate for the additional diff marker at the line start.
The code is heavily based on how gitk handles tabs.
--- git-gui.sh | 1 + lib/diff.tcl | 20 +++++++++++++++++++- lib/option.tcl | 1 + 3 files changed, 21 insertions(+), 1 deletions(-)
git-gui.sh +1 -0
@@ -892,6 +892,7 @@ set default_config(gui.fontdiff) [font configure font_diff] set default_config(gui.maxfilesdisplayed) 5000 set default_config(gui.usettk) 1 set default_config(gui.warndetachedcommit) 1 +set default_config(gui.tabsize) 8 set font_descs { {fontui font_ui {mc "Main Font"}} {fontdiff font_diff {mc "Diff/Console Font"}}
lib/diff.tcl +19 -1
@@ -1,6 +1,19 @@ # git-gui diff viewer # Copyright (C) 2006, 2007 Shawn Pearce +proc apply_tab_size {{firsttab {}}} { + global have_tk85 repo_config ui_diff + + set w [font measure font_diff "0"] + if {$have_tk85 && $firsttab != 0} { + $ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]] + } elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} { + $ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}] + } else { + $ui_diff configure -tabs {} + } +} + proc clear_diff {} { global ui_diff current_diff_path current_diff_header global ui_index ui_workdir
@@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} { set cont_info [list $scroll_pos $callback] + apply_tab_size 0 + if {[string first {U} $m] >= 0} { merge_load_stages $path [list show_unmerged_diff $cont_info] } elseif {$m eq {_O}} {
@@ -398,7 +413,10 @@ proc read_diff {fd conflict_size cont_info} { # -- Automatically detect if this is a 3 way diff. # - if {[string match {@@@ *} $line]} {set is_3way_diff 1} + if {[string match {@@@ *} $line]} { + set is_3way_diff 1 + apply_tab_size 1 + } if {$::current_diff_inheader} {
lib/option.tcl +0 -0
@@ -159,6 +159,7 @@ proc do_options {} { {c gui.encoding {mc "Default File Contents Encoding"}} {b gui.warndetachedcommit {mc "Warn before committing to a detached
head"}}
{s gui.stageuntracked {mc "Staging of untracked files"} {list "yes"
"no" "ask"}}
+ {i-1..99 gui.tabsize {mc "Tab spacing"}}
} {
set type [lindex $option 0]
set name [lindex $option 1]
---------------
Regards,
Krzysztof
Quoted 4 lines · pb158 <[email protected]> writes:
Home of the original description and the author of the patch:
Quoted 8 lines
Why not added this useful little patch for git-gui ?
( this patch resolve my problem with 8 spaces tab Linux Eclipse + Java program source + git gui
and I apply locally it to each new version git before source compilation )original content of the message from the link above:
I do not use git-gui, and I do not speak very good tcl/tk either, so I won't comment on the patch itself (Cc'ed its maintainer Pat), but thanks for trying to relay, anyway.
Quoted 9 lines
----------------------
For Tk 8.5 the "wordprocessor" mode allows us to get a bit fancy for merge diffs and intend the tabs by one to compensate for the additional diff marker at the line start.
The code is heavily based on how gitk handles tabs.
Signed-off-by Michael Lutz <michi@xxxxxxxxxxxxxx>
With this, the author refuses to be contacted if/when any question arises wrt the provenance of the patch, which is not a usable form of a sign-off. When you relay a change from somebody else who claims that he has rights to contribute the change to the project, and you have the rights to relay that change to the project, please also add your own sign-off. For further details, please check "(5) Sign your work" section of Documentation/SubmittingPatches. I am guessing that Michael is asserting DCO 1.1 (a) and (d), and you without a name but only a number are asserting DCO 1.1 (c) and (d).
Thanks.
Quoted 86 lines
--- git-gui.sh | 1 + lib/diff.tcl | 20 +++++++++++++++++++- lib/option.tcl | 1 + 3 files changed, 21 insertions(+), 1 deletions(-)git-gui.sh +0
-0@@ -892,6 +892,7 @@ set default_config(gui.fontdiff) [font configure
font_diff]
setdefault_config(gui.maxfilesdisplayed)5000
setdefault_config(gui.usettk)1
setdefault_config(gui.warndetachedcommit)1git-gui.sh +1
-0+set default_config(gui.tabsize) 8 set font_descs { {fontui font_ui {mc "Main Font"}} {fontdiff font_diff {mc "Diff/Console Font"}}lib/diff.tcl +6
-0@@ -1,6 +1,19 @@ # git-gui diff viewer # Copyright (C) 2006, 2007 Shawn Pearce +proc apply_tab_size {{firsttab {}}} { + global have_tk85 repo_config ui_diff + + set w [font measure font_diff "0"] + if {$have_tk85 && $firsttab != 0} { + $ui_diff configure -tabs [list [expr {$firsttab * $w}][expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]
lib/diff.tcl +9
-0+ } elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} { + $ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}] + } else { + $ui_diff configure -tabs {} + } +} + proc clear_diff {} { global ui_diff current_diff_path current_diff_header global ui_index ui_workdir@@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} { set cont_info [list $scroll_pos $callback] + apply_tab_size 0 + if {[string first {U} $m] >= 0} { merge_load_stages $path [list show_unmerged_diff $cont_info]lib/diff.tcl +4
-1} elseif {$m eq {_O}} {@@ -398,7 +413,10 @@ proc read_diff {fd conflict_size cont_info} { # -- Automatically detect if this is a 3 way diff. # - if {[string match {@@@ *} $line]} {set is_3way_diff 1} + if {[string match {@@@ *} $line]} { + set is_3way_diff 1 + apply_tab_size 1 + } if {$::current_diff_inheader} {lib/option.tcl +1
-0@@ -159,6 +159,7 @@ proc do_options {} { {c gui.encoding {mc "Default File Contents Encoding"}} {b gui.warndetachedcommit {mc "Warn before committing to a detached head"}} {s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}} + {i-1..99 gui.tabsize {mc "Tab spacing"}} } {lib/option.tcl +0
-1set type [lindex $option 0] set name [lindex $option 1] ---------------Regards,
Krzysztof
Quoted 12 lines · Junio C Hamano
I do not use git-gui, and I do not speak very good tcl/tk either, so I won't comment on the patch itself (Cc'ed its maintainer Pat), but thanks for trying to relay, anyway.
Quoted 8 lines
----------------------
For Tk 8.5 the "wordprocessor" mode allows us to get a bit fancy for merge diffs and intend the tabs by one to compensate for the additional diff marker at the line start.
The code is heavily based on how gitk handles tabs.
Quoted 8 lines
Quoted 1 line
Signed-off-by Michael Lutz <michi@xxxxxxxxxxxxxx>With this, the author refuses to be contacted if/when any question arises wrt the provenance of the patch, which is not a usable form of a sign-off. When you relay a change from somebody else who claims that he has rights to contribute the change to the project, and you have the rights to relay that change to the project, please also add your own sign-off.
Heh, I spoke too fast. The original is at $gmane/190576 [*1*] and the butchering of the address is only due to the the spinics list archive pb158 grabbed his or her copy from.
So we don't need any forwarder's sign-off. As long as the change is acceptable (I have no opinion on it), the original can be directly applied.
[References]
*1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw
Quoted 4 lines · Junio C Hamano
[References]
*1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw
This solves the problem, I hope that the patch will come to git source and will not be forgotten as before ( http://thread.gmane.org/gmane.comp.version-control.git/190576/focus=192034 )
Krzysztof
Quoted 7 lines · pb158 <[email protected]> writes:
Quoted 4 lines · Junio C Hamano
[References]
*1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw
This solves the problem, I hope ...
Not so fast. It could be that people were not interested in the change for a reason when it was posted. We'll see ;-)