{"thread":{"id":"37595","subject":"[PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","startedAt":"2014-09-19T14:33:53Z","lastAt":"2014-09-19T18:05:25Z","messageCount":5,"participants":["pb158","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"249660","messageId":"lvhesi$qqs$1@ger.gmane.org","threadId":"37595","inReplyTo":null,"subject":"[PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","fromName":"pb158","fromEmail":"pb158@tlen.pl","sentAt":"2014-09-19T14:33:53Z","receivedAt":"2014-09-19T14:33:53Z","isPatch":true,"sender":{"key":"pb158@tlen.pl","avatar":null},"body":"Home of the original description and the author of the patch:\n\nhttp://www.spinics.net/lists/git/msg174415.html\n\nWhy not added this useful little patch for git-gui ?\n\n( this patch resolve my problem with 8 spaces tab Linux Eclipse + Java \nprogram source + git gui\nand I apply locally it to each new version git before source compilation )\n\noriginal content of the message from the link above:\n\n----------------------\n\nFor Tk 8.5 the \"wordprocessor\" mode allows us to get a bit fancy for merge\ndiffs and intend the tabs by one to compensate for the additional diff\nmarker at the line start.\n\nThe code is heavily based on how gitk handles tabs.\n\nSigned-off-by: Michael Lutz <michi@xxxxxxxxxxxxxx>\n---\n  git-gui.sh     |    1 +\n  lib/diff.tcl   |   20 +++++++++++++++++++-\n  lib/option.tcl |    1 +\n  3 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex ba4e5c1..22d7665 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -892,6 +892,7 @@ set default_config(gui.fontdiff) [font configure \nfont_diff]\n  set default_config(gui.maxfilesdisplayed) 5000\n  set default_config(gui.usettk) 1\n  set default_config(gui.warndetachedcommit) 1\n+set default_config(gui.tabsize) 8\n  set font_descs {\n  \t{fontui   font_ui   {mc \"Main Font\"}}\n  \t{fontdiff font_diff {mc \"Diff/Console Font\"}}\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex ec44055..f314197 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -1,6 +1,19 @@\n  # git-gui diff viewer\n  # Copyright (C) 2006, 2007 Shawn Pearce\n\n+proc apply_tab_size {{firsttab {}}} {\n+\tglobal have_tk85 repo_config ui_diff\n+\n+\tset w [font measure font_diff \"0\"]\n+\tif {$have_tk85 && $firsttab != 0} {\n+\t\t$ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr \n{($firsttab + $repo_config(gui.tabsize)) * $w}]]\n+\t} elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n+\t\t$ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n+\t} else {\n+\t\t$ui_diff configure -tabs {}\n+\t}\n+}\n+\n  proc clear_diff {} {\n  \tglobal ui_diff current_diff_path current_diff_header\n  \tglobal ui_index ui_workdir\n@@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}} \n{callback {}}} {\n\n  \tset cont_info [list $scroll_pos $callback]\n\n+\tapply_tab_size 0\n+\n  \tif {[string first {U} $m] >= 0} {\n  \t\tmerge_load_stages $path [list show_unmerged_diff $cont_info]\n  \t} elseif {$m eq {_O}} {\n@@ -398,7 +413,10 @@ proc read_diff {fd conflict_size cont_info} {\n\n  \t\t# -- Automatically detect if this is a 3 way diff.\n  \t\t#\n-\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n+\t\tif {[string match {@@@ *} $line]} {\n+\t\t\tset is_3way_diff 1\n+\t\t\tapply_tab_size 1\n+\t\t}\n\n  \t\tif {$::current_diff_inheader} {\n\ndiff --git a/lib/option.tcl b/lib/option.tcl\nindex 0cf1da1..b940c44 100644\n--- a/lib/option.tcl\n+++ b/lib/option.tcl\n@@ -159,6 +159,7 @@ proc do_options {} {\n  \t\t{c gui.encoding {mc \"Default File Contents Encoding\"}}\n  \t\t{b gui.warndetachedcommit {mc \"Warn before committing to a detached \nhead\"}}\n  \t\t{s gui.stageuntracked {mc \"Staging of untracked files\"} {list \"yes\" \n\"no\" \"ask\"}}\n+\t\t{i-1..99 gui.tabsize {mc \"Tab spacing\"}}\n  \t\t} {\n  \t\tset type [lindex $option 0]\n  \t\tset name [lindex $option 1]\n\n---------------\n\nRegards,\n\nKrzysztof\n"},{"id":"249661","messageId":"xmqqd2aro8fx.fsf@gitster.dls.corp.google.com","threadId":"37595","inReplyTo":"lvhesi$qqs$1@ger.gmane.org","subject":"Re: [PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-19T16:56:34Z","receivedAt":"2014-09-19T16:56:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"pb158 <pb158@tlen.pl> writes:\n\n> Home of the original description and the author of the patch:\n>\n> http://www.spinics.net/lists/git/msg174415.html\n>\n> Why not added this useful little patch for git-gui ?\n>\n> ( this patch resolve my problem with 8 spaces tab Linux Eclipse + Java\n> program source + git gui\n> and I apply locally it to each new version git before source compilation )\n>\n> original content of the message from the link above:\n>\n\nI do not use git-gui, and I do not speak very good tcl/tk either, so\nI won't comment on the patch itself (Cc'ed its maintainer Pat), but\nthanks for trying to relay, anyway.\n\n> ----------------------\n>\n> For Tk 8.5 the \"wordprocessor\" mode allows us to get a bit fancy for merge\n> diffs and intend the tabs by one to compensate for the additional diff\n> marker at the line start.\n>\n> The code is heavily based on how gitk handles tabs.\n>\n> Signed-off-by: Michael Lutz <michi@xxxxxxxxxxxxxx>\n\nWith this, the author refuses to be contacted if/when any question\narises wrt the provenance of the patch, which is not a usable form\nof a sign-off.  When you relay a change from somebody else who\nclaims that he has rights to contribute the change to the project,\nand you have the rights to relay that change to the project, please\nalso add your own sign-off.  For further details, please check \"(5)\nSign your work\" section of Documentation/SubmittingPatches.  I am\nguessing that Michael is asserting DCO 1.1 (a) and (d), and you\nwithout a name but only a number are asserting DCO 1.1 (c) and (d).\n\nThanks.\n\n> ---\n>  git-gui.sh     |    1 +\n>  lib/diff.tcl   |   20 +++++++++++++++++++-\n>  lib/option.tcl |    1 +\n>  3 files changed, 21 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-gui.sh b/git-gui.sh\n> index ba4e5c1..22d7665 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -892,6 +892,7 @@ set default_config(gui.fontdiff) [font configure\n> font_diff]\n>  set default_config(gui.maxfilesdisplayed) 5000\n>  set default_config(gui.usettk) 1\n>  set default_config(gui.warndetachedcommit) 1\n> +set default_config(gui.tabsize) 8\n>  set font_descs {\n>  \t{fontui   font_ui   {mc \"Main Font\"}}\n>  \t{fontdiff font_diff {mc \"Diff/Console Font\"}}\n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index ec44055..f314197 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -1,6 +1,19 @@\n>  # git-gui diff viewer\n>  # Copyright (C) 2006, 2007 Shawn Pearce\n>\n> +proc apply_tab_size {{firsttab {}}} {\n> +\tglobal have_tk85 repo_config ui_diff\n> +\n> +\tset w [font measure font_diff \"0\"]\n> +\tif {$have_tk85 && $firsttab != 0} {\n> +\t\t$ui_diff configure -tabs [list [expr {$firsttab * $w}]\n> [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]\n> +\t} elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n> +\t\t$ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n> +\t} else {\n> +\t\t$ui_diff configure -tabs {}\n> +\t}\n> +}\n> +\n>  proc clear_diff {} {\n>  \tglobal ui_diff current_diff_path current_diff_header\n>  \tglobal ui_index ui_workdir\n> @@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}}\n> {callback {}}} {\n>\n>  \tset cont_info [list $scroll_pos $callback]\n>\n> +\tapply_tab_size 0\n> +\n>  \tif {[string first {U} $m] >= 0} {\n>  \t\tmerge_load_stages $path [list show_unmerged_diff $cont_info]\n>  \t} elseif {$m eq {_O}} {\n> @@ -398,7 +413,10 @@ proc read_diff {fd conflict_size cont_info} {\n>\n>  \t\t# -- Automatically detect if this is a 3 way diff.\n>  \t\t#\n> -\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n> +\t\tif {[string match {@@@ *} $line]} {\n> +\t\t\tset is_3way_diff 1\n> +\t\t\tapply_tab_size 1\n> +\t\t}\n>\n>  \t\tif {$::current_diff_inheader} {\n>\n> diff --git a/lib/option.tcl b/lib/option.tcl\n> index 0cf1da1..b940c44 100644\n> --- a/lib/option.tcl\n> +++ b/lib/option.tcl\n> @@ -159,6 +159,7 @@ proc do_options {} {\n>  \t\t{c gui.encoding {mc \"Default File Contents Encoding\"}}\n>  \t\t{b gui.warndetachedcommit {mc \"Warn before committing\n> to a detached head\"}}\n>  \t\t{s gui.stageuntracked {mc \"Staging of untracked\n> files\"} {list \"yes\" \"no\" \"ask\"}}\n> +\t\t{i-1..99 gui.tabsize {mc \"Tab spacing\"}}\n>  \t\t} {\n>  \t\tset type [lindex $option 0]\n>  \t\tset name [lindex $option 1]\n>\n> ---------------\n>\n> Regards,\n>\n> Krzysztof\n"},{"id":"249662","messageId":"xmqq8ulfo868.fsf@gitster.dls.corp.google.com","threadId":"37595","inReplyTo":"xmqqd2aro8fx.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-19T17:02:23Z","receivedAt":"2014-09-19T17:02:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I do not use git-gui, and I do not speak very good tcl/tk either, so\n> I won't comment on the patch itself (Cc'ed its maintainer Pat), but\n> thanks for trying to relay, anyway.\n>\n>> ----------------------\n>>\n>> For Tk 8.5 the \"wordprocessor\" mode allows us to get a bit fancy for merge\n>> diffs and intend the tabs by one to compensate for the additional diff\n>> marker at the line start.\n>>\n>> The code is heavily based on how gitk handles tabs.\n>>\n>> Signed-off-by: Michael Lutz <michi@xxxxxxxxxxxxxx>\n>\n> With this, the author refuses to be contacted if/when any question\n> arises wrt the provenance of the patch, which is not a usable form\n> of a sign-off.  When you relay a change from somebody else who\n> claims that he has rights to contribute the change to the project,\n> and you have the rights to relay that change to the project, please\n> also add your own sign-off.\n\nHeh, I spoke too fast.  The original is at $gmane/190576 [*1*] and\nthe butchering of the address is only due to the the spinics list\narchive pb158 grabbed his or her copy from.\n\nSo we don't need any forwarder's sign-off.  As long as the change is\nacceptable (I have no opinion on it), the original can be directly\napplied.\n\n\n[References] \n\n*1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw\n"},{"id":"249672","messageId":"lvhq23$fq6$1@ger.gmane.org","threadId":"37595","inReplyTo":"xmqq8ulfo868.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","fromName":"pb158","fromEmail":"pb158@tlen.pl","sentAt":"2014-09-19T17:44:34Z","receivedAt":"2014-09-19T17:44:34Z","isPatch":true,"sender":{"key":"pb158@tlen.pl","avatar":null},"body":"On 19.09.2014 19:02, Junio C Hamano wrote:\n> [References]\n>\n> *1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw\n>\n\nThis solves the problem, I hope that the patch will come to git source \nand will not be forgotten as before ( \nhttp://thread.gmane.org/gmane.comp.version-control.git/190576/focus=192034 )\n\nKrzysztof\n"},{"id":"249674","messageId":"xmqqsijnmqoq.fsf@gitster.dls.corp.google.com","threadId":"37595","inReplyTo":"lvhq23$fq6$1@ger.gmane.org","subject":"Re: [PATCH] git-gui: add configurable tab size to the diff view git-gui - why not added to git-gui ?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-19T18:05:25Z","receivedAt":"2014-09-19T18:05:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"pb158 <pb158@tlen.pl> writes:\n\n> On 19.09.2014 19:02, Junio C Hamano wrote:\n>> [References]\n>>\n>> *1* http://article.gmane.org/gmane.comp.version-control.git/190576/raw\n>>\n>\n> This solves the problem, I hope ...\n\nNot so fast.  It could be that people were not interested in the\nchange for a reason when it was posted.  We'll see ;-)\n"}]}