Skip to content

Commit b31fb63

Browse files
committed
* https://github.com/j6t/git-gui: git gui: add directly calling merge tool from configuration git-gui: strip commit messages less aggressively git-gui: strip comments and consecutive empty lines from commit messages
2 parents facbe4f + e503389 commit b31fb63

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

git-gui/lib/commit.tcl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,17 @@ You must stage at least 1 file before you can commit.
207207

208208
# -- A message is required.
209209
#
210-
set msg [string trim [$ui_comm get 1.0 end]]
210+
set msg [$ui_comm get 1.0 end]
211+
# Strip trailing whitespace
211212
regsub -all -line {[ \t\r]+$} $msg {} msg
213+
# Strip comment lines
214+
regsub -all {(^|\n)#[^\n]*} $msg {\1} msg
215+
# Strip leading empty lines
216+
regsub {^\n*} $msg {} msg
217+
# Compress consecutive empty lines
218+
regsub -all {\n{3,}} $msg "\n\n" msg
219+
# Strip trailing empty line
220+
regsub {\n\n$} $msg "\n" msg
212221
if {$msg eq {}} {
213222
error_popup [mc "Please supply a commit message.
214223

git-gui/lib/mergetool.tcl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,25 @@ proc merge_resolve_tool2 {} {
272272
}
273273
}
274274
default {
275-
error_popup [mc "Unsupported merge tool '%s'" $tool]
276-
return
275+
set tool_cmd [get_config mergetool.$tool.cmd]
276+
if {$tool_cmd ne {}} {
277+
if {([string first {[} $tool_cmd] != -1) || ([string first {]} $tool_cmd] != -1)} {
278+
error_popup [mc "Unable to process square brackets in \"mergetool.%s.cmd\" configuration option.
279+
280+
Please remove the square brackets." $tool]
281+
return
282+
} else {
283+
set cmdline {}
284+
foreach command_part $tool_cmd {
285+
lappend cmdline [subst -nobackslashes -nocommands $command_part]
286+
}
287+
}
288+
} else {
289+
error_popup [mc "Unsupported merge tool '%s'.
290+
291+
To use this tool, configure \"mergetool.%s.cmd\" as shown in the git-config manual page." $tool $tool]
292+
return
293+
}
277294
}
278295
}
279296

0 commit comments

Comments
 (0)