Skip to content

Commit bb52cda

Browse files
Wolfgang Faustj6t
authored andcommitted
git-gui: grey out comment lines in commit message
Comment lines are stripped by wash_commit_message, but there is no indication in the UI that they are special and will be removed. Grey these lines out to indicate that they will be removed. Signed-off-by: Wolfgang Faust <contrib-git@wolfgangfaust.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 8d55f6e commit bb52cda

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

git-gui.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,6 +3900,24 @@ if {[winfo exists $ui_comm]} {
39003900

39013901
backup_commit_buffer
39023902

3903+
# Grey out comment lines (which are stripped from the final commit message by
3904+
# wash_commit_message).
3905+
$ui_comm tag configure commit_comment -foreground gray
3906+
proc dim_commit_comment_lines {} {
3907+
global ui_comm comment_string
3908+
$ui_comm tag remove commit_comment 1.0 end
3909+
set text [$ui_comm get 1.0 end]
3910+
# See also cmt_rx in wash_commit_message
3911+
set cmt_rx [strcat {^} [regsub -all {\W} $comment_string {\\&}]]
3912+
set ranges [regexp -all -indices -inline -line -- $cmt_rx $text]
3913+
foreach pair $ranges {
3914+
set idx "1.0 + [lindex $pair 0] chars"
3915+
$ui_comm tag add commit_comment $idx "$idx lineend + 1 char"
3916+
}
3917+
}
3918+
dim_commit_comment_lines
3919+
bind $ui_comm <<Modified>> { after idle dim_commit_comment_lines }
3920+
39033921
# -- If the user has aspell available we can drive it
39043922
# in pipe mode to spellcheck the commit message.
39053923
#

0 commit comments

Comments
 (0)