diff options
| author | Shulhan <ms@kilabit.info> | 2023-05-02 02:05:46 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-04-09 19:00:06 +0700 |
| commit | c3561b12139efbb17bf7dbc07b84e3debed1b017 (patch) | |
| tree | d42b8a36eab15320ed9422263e63bd5cff583b6b | |
| parent | e1d65ab098816914b24ac1ed954063c56e3fd08d (diff) | |
| download | git-c3561b12139efbb17bf7dbc07b84e3debed1b017.tar.xz | |
gitk-git: add option to remove indentation on the commit comment
Indentation make us hard to copy-paste the content of commit comment
from gitk to other medium, especially when creating change log.
The "git log --pretty=raw" command does not have option to re-format
the pretty output again, so the only way to remove indentation is
by trimming left space line by line.
This changes add option "Remove indentation on comment" under
"General" option in Preference. If its checked the comment will
rendered without left space; otherwise it will displayed as usual.
| -rwxr-xr-x | gitk-git/gitk | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk index 91b16a3bb0..831e2e0178 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -1906,6 +1906,7 @@ proc readcommit {id} { proc parsecommit {id contents listed} { global commitinfo + global no_indent set inhdr 1 set comment {} @@ -1949,11 +1950,22 @@ proc parsecommit {id contents listed} { # if we got this via git cat-file, add the indentation set newcomment {} foreach line [split $comment "\n"] { - append newcomment " " + if {!$no_indent} { + append newcomment " " + } append newcomment $line append newcomment "\n" } set comment $newcomment + } else { + if {$no_indent} { + set newcomment {} + foreach line [split $comment "\n"] { + append newcomment [string range $line 4 end] + append newcomment "\n" + } + set comment $newcomment + } } set hasnote [string first "\nNotes:\n" $contents] set diff "" @@ -11794,6 +11806,10 @@ proc prefspage_general {notebook} { grid x $page.webbrowserl $page.webbrowser -sticky ew grid configure $page.webbrowser -padx {0 5} + ttk::checkbutton $page.no_indent -variable no_indent \ + -text [mc "Remove indentation on comment"] + grid x $page.no_indent -sticky w + grid columnconfigure $page 2 -weight 1 return $page @@ -12097,6 +12113,7 @@ proc prefsok {} { global oldprefs prefstop fontpref treediffs global {*}$::config_variables global ctext + global no_indent catch {destroy $prefstop} unset prefstop @@ -12151,6 +12168,9 @@ proc prefsok {} { if {$wrapdefault != $oldprefs(wrapdefault)} { $ctext configure -wrap $wrapdefault } + if {$no_indent != $oldprefs(no_indent)} { + reloadcommits + } } proc formatdate {d} { @@ -12658,6 +12678,7 @@ set autocopy 0 set autoselect 1 set autosellen $hashlength set perfile_attrs 0 +set no_indent 0 if {[tk windowingsystem] eq "aqua"} { set extdifftool "opendiff" @@ -12787,6 +12808,7 @@ set config_variables { maxrefs maxwidth mergecolors + no_indent perfile_attrs reflinecolor refstohide @@ -13033,3 +13055,4 @@ getcommits {} # indent-tabs-mode: t # tab-width: 8 # End: +# vim: ts=4 expandtab |
