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 <dev+git@drbeat.li> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Beat Bolli committed
Jul 18, 2015 at 13:15 UTC
d835dbb91fe246d123dc81f6a317d73518ecef46
1 file changed
+15
gitk
+15
@@ -2618,6 +2618,7 @@ proc makewindow {} {
2618
{mc "Diff selected -> this" command {diffvssel 1}}
2619
{mc "Make patch" command mkpatch}
2620
{mc "Create tag" command mktag}
2621
+ {mc "Copy commit summary" command copysummary}
2622
{mc "Write commit to file" command writecommit}
2623
{mc "Create new branch" command mkbranch}
2624
{mc "Cherry-pick this commit" command cherrypick}
@@ -9360,6 +9361,20 @@ proc mktaggo {} {
9361
mktagcan
9362
}
9363
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
+
9378
proc writecommit {} {
9379
global rowmenuid wrcomtop commitinfo wrcomcmd NS
9380