Skip to content

Commit d835dbb

Browse files
bbollipaulusmack
authored andcommitted
gitk: Add a "Copy commit summary" command
When referring to earlier commits in commit messages or other text, one of the established formats is <abbrev-sha> ("<summary>", <author-date>) Add a "Copy commit summary" command to the context menu that puts this text for the currently selected commit on the clipboard. This makes it easy for our users to create well-formatted commit references. The <abbrev-sha> is produced with the %h format specifier to make it unique. Its length can be controlled with the gitk preference "Auto-select SHA1 (length)", or, if this preference is set to its default value (40), with the Git config setting core.abbrev. Signed-off-by: Beat Bolli <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent dfed7f9 commit d835dbb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gitk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,6 +2618,7 @@ proc makewindow {} {
26182618
{mc "Diff selected -> this" command {diffvssel 1}}
26192619
{mc "Make patch" command mkpatch}
26202620
{mc "Create tag" command mktag}
2621+
{mc "Copy commit summary" command copysummary}
26212622
{mc "Write commit to file" command writecommit}
26222623
{mc "Create new branch" command mkbranch}
26232624
{mc "Cherry-pick this commit" command cherrypick}
@@ -9360,6 +9361,20 @@ proc mktaggo {} {
93609361
mktagcan
93619362
}
93629363

9364+
proc copysummary {} {
9365+
global rowmenuid autosellen
9366+
9367+
set format "%h (\"%s\", %ad)"
9368+
set cmd [list git show -s --pretty=format:$format --date=short]
9369+
if {$autosellen < 40} {
9370+
lappend cmd --abbrev=$autosellen
9371+
}
9372+
set summary [eval exec $cmd $rowmenuid]
9373+
9374+
clipboard clear
9375+
clipboard append $summary
9376+
}
9377+
93639378
proc writecommit {} {
93649379
global rowmenuid wrcomtop commitinfo wrcomcmd NS
93659380

0 commit comments

Comments
 (0)