{"thread":{"id":"39860","subject":"[PATCH v2] gitk: Add a \"Copy commit summary\" command","startedAt":"2015-07-16T15:29:25Z","lastAt":"2015-07-18T12:45:34Z","messageCount":9,"participants":["Beat Bolli","Junio C Hamano","Johannes Sixt","Stefan Haller","Paul Mackerras"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"266196","messageId":"1437060565-4716-1-git-send-email-dev+git@drbeat.li","threadId":"39860","inReplyTo":null,"subject":"[PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2015-07-16T15:29:25Z","receivedAt":"2015-07-16T15:29:25Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"When referring to earlier commits in commit messages or other text, one\nof the established formats is\n\n    <abbrev-sha> (\"<summary>\", <author-date>)\n\nAdd a \"Copy commit summary\" command to the context menu that puts this\ntext for the currently selected commit on the clipboard. This makes it\neasy for our users to create well-formatted commit references.\n\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\nCc: Paul Mackerras <paulus@samba.org>\n---\n gitk-git/gitk | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 9a2daf3..72a2756 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -2617,6 +2617,7 @@ proc makewindow {} {\n \t{mc \"Diff selected -> this\" command {diffvssel 1}}\n \t{mc \"Make patch\" command mkpatch}\n \t{mc \"Create tag\" command mktag}\n+\t{mc \"Copy commit summary\" command copysummary}\n \t{mc \"Write commit to file\" command writecommit}\n \t{mc \"Create new branch\" command mkbranch}\n \t{mc \"Cherry-pick this commit\" command cherrypick}\n@@ -9341,6 +9342,19 @@ proc mktaggo {} {\n     mktagcan\n }\n \n+proc copysummary {} {\n+    global rowmenuid commitinfo\n+\n+    set id [string range $rowmenuid 0 7]\n+    set info $commitinfo($rowmenuid)\n+    set commit [lindex $info 0]\n+    set date [formatdate [lindex $info 2]]\n+    set summary \"$id (\\\"$commit\\\", $date)\"\n+\n+    clipboard clear\n+    clipboard append $summary\n+}\n+\n proc writecommit {} {\n     global rowmenuid wrcomtop commitinfo wrcomcmd NS\n \n-- \n2.1.4\n"},{"id":"266198","messageId":"xmqq380o593i.fsf@gitster.dls.corp.google.com","threadId":"39860","inReplyTo":"1437060565-4716-1-git-send-email-dev+git@drbeat.li","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-16T17:02:41Z","receivedAt":"2015-07-16T17:02:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Beat Bolli <dev+git@drbeat.li> writes:\n\n> When referring to earlier commits in commit messages or other text, one\n> of the established formats is\n>\n>     <abbrev-sha> (\"<summary>\", <author-date>)\n> ...\n> +proc copysummary {} {\n> +    global rowmenuid commitinfo\n> +\n> +    set id [string range $rowmenuid 0 7]\n> +    set info $commitinfo($rowmenuid)\n> +    set commit [lindex $info 0]\n\n7 hexdigits is not always an appropriate value for all projects.\nThe minimum necessary to guarantee uniqueness varies on project, and\nit is not a good idea to hardcode such a small value.  Not-so-old\nLinux kernel history seems to use at least 12, for example.\n\nI believe that the \"one of the established formats\" comes from a\n\"git one\" alias I published somewhere long time ago, that did\nsomething like this:\n\n  git show -s --abbrev=8 --pretty='format:%h (%s, %ai' \"$@\" |\n  sed -e 's/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/'\n\nwhere the combination of --abbrev=8 and format:%h asks for a unique\nabbreviation that is at least 8 hexdigits long but can use more than\n8 if it is not long enough to uniquely identify the given commit.\n\nI do not offhand know how $commitinfo is populated, but perhaps you\ncan tweak that code to ask for both %H (for the full commit object\nID) and %h (for the unique abbreviation of appropriate length) and\nstore the value for %h to a new field in the $commitinfo($rowmenuid)\narray, so that you do not have to have such a hard-coded truncation\nhere?\n\n> +    set date [formatdate [lindex $info 2]]\n> +    set summary \"$id (\\\"$commit\\\", $date)\"\n> +\n> +    clipboard clear\n> +    clipboard append $summary\n> +}\n> +\n>  proc writecommit {} {\n>      global rowmenuid wrcomtop commitinfo wrcomcmd NS\n"},{"id":"266209","messageId":"55A818B1.4000205@kdbg.org","threadId":"39860","inReplyTo":"1437060565-4716-1-git-send-email-dev+git@drbeat.li","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-07-16T20:48:49Z","receivedAt":"2015-07-16T20:48:49Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 16.07.2015 um 17:29 schrieb Beat Bolli:\n> When referring to earlier commits in commit messages or other text, one\n> of the established formats is\n>\n>      <abbrev-sha> (\"<summary>\", <author-date>)\n>\n> Add a \"Copy commit summary\" command to the context menu that puts this\n> text for the currently selected commit on the clipboard. This makes it\n> easy for our users to create well-formatted commit references.\n>\n> Signed-off-by: Beat Bolli <dev+git@drbeat.li>\n> Cc: Paul Mackerras <paulus@samba.org>\n> ---\n>   gitk-git/gitk | 14 ++++++++++++++\n>   1 file changed, 14 insertions(+)\n>\n> diff --git a/gitk-git/gitk b/gitk-git/gitk\n> index 9a2daf3..72a2756 100755\n> --- a/gitk-git/gitk\n> +++ b/gitk-git/gitk\n> @@ -2617,6 +2617,7 @@ proc makewindow {} {\n>   \t{mc \"Diff selected -> this\" command {diffvssel 1}}\n>   \t{mc \"Make patch\" command mkpatch}\n>   \t{mc \"Create tag\" command mktag}\n> +\t{mc \"Copy commit summary\" command copysummary}\n>   \t{mc \"Write commit to file\" command writecommit}\n>   \t{mc \"Create new branch\" command mkbranch}\n>   \t{mc \"Cherry-pick this commit\" command cherrypick}\n> @@ -9341,6 +9342,19 @@ proc mktaggo {} {\n>       mktagcan\n>   }\n>\n> +proc copysummary {} {\n> +    global rowmenuid commitinfo\n> +\n> +    set id [string range $rowmenuid 0 7]\n\nYou abbreviate the commit name to 7 characters. This is too short for \ncertain repositories to remain unique. In my group, it is customary to \nabbreviate to 8 charaters. This reduces the usefulness for my use. If \nyou don't want to make this a configuration I would suggest to aim for a \nlonger commit name as it is simpler to delete excess letters after \npasting than to add back the missing ones.\n\nExcept for this, I like the idea.\n\n> +    set info $commitinfo($rowmenuid)\n> +    set commit [lindex $info 0]\n> +    set date [formatdate [lindex $info 2]]\n> +    set summary \"$id (\\\"$commit\\\", $date)\"\n> +\n> +    clipboard clear\n> +    clipboard append $summary\n> +}\n> +\n>   proc writecommit {} {\n>       global rowmenuid wrcomtop commitinfo wrcomcmd NS\n>\n>\n\n-- Hannes\n"},{"id":"266227","messageId":"1m7p7z9.36ajnyli8ph2M%lists@haller-berlin.de","threadId":"39860","inReplyTo":"xmqq380o593i.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2015-07-17T08:50:56Z","receivedAt":"2015-07-17T08:50:56Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> Beat Bolli <dev+git@drbeat.li> writes:\n> \n> > When referring to earlier commits in commit messages or other text, one\n> > of the established formats is\n> >\n> >     <abbrev-sha> (\"<summary>\", <author-date>)\n> > ...\n> > +proc copysummary {} {\n> > +    global rowmenuid commitinfo\n> > +\n> > +    set id [string range $rowmenuid 0 7]\n> > +    set info $commitinfo($rowmenuid)\n> > +    set commit [lindex $info 0]\n> \n> 7 hexdigits is not always an appropriate value for all projects.\n> The minimum necessary to guarantee uniqueness varies on project, and\n> it is not a good idea to hardcode such a small value.  Not-so-old\n> Linux kernel history seems to use at least 12, for example.\n> \n> I believe that the \"one of the established formats\" comes from a\n> \"git one\" alias I published somewhere long time ago, that did\n> something like this:\n> \n>   git show -s --abbrev=8 --pretty='format:%h (%s, %ai' \"$@\" |\n>   sed -e 's/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/'\n> \n> where the combination of --abbrev=8 and format:%h asks for a unique\n> abbreviation that is at least 8 hexdigits long but can use more than\n> 8 if it is not long enough to uniquely identify the given commit.\n\nFor the intended use case of this feature (referring to earlier commits\nin commit messages), guaranteeing uniqueness isn't sufficiant either.\nWhat is unique at the time of creating the commit might no longer be\nunique a few years later.\n\nSo one strategy would be to add one or two digits to what %h returns, to\ngive some future leeway; or rely on the user to configure core.abbrev\nappropriatly for their project; or just make the hard-coded value\nconfigurable, as Hannes suggests.\n\nFWIW, a discussion of this that I find useful can be found here:\n<http://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/>.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"266228","messageId":"748fbe6a4bf00ec8afcd6e4c7d5176bb@drbeat.li","threadId":"39860","inReplyTo":"1m7p7z9.36ajnyli8ph2M%lists@haller-berlin.de","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2015-07-17T09:16:56Z","receivedAt":"2015-07-17T09:16:56Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"On 2015-07-17 10:50, lists@haller-berlin.de wrote:\n> Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Beat Bolli <dev+git@drbeat.li> writes:\n>>\n>> > When referring to earlier commits in commit messages or other \n>> text, one\n>> > of the established formats is\n>> >\n>> >     <abbrev-sha> (\"<summary>\", <author-date>)\n>> > ...\n>> > +proc copysummary {} {\n>> > +    global rowmenuid commitinfo\n>> > +\n>> > +    set id [string range $rowmenuid 0 7]\n>> > +    set info $commitinfo($rowmenuid)\n>> > +    set commit [lindex $info 0]\n>>\n>> 7 hexdigits is not always an appropriate value for all projects.\n>> The minimum necessary to guarantee uniqueness varies on project, and\n>> it is not a good idea to hardcode such a small value.  Not-so-old\n>> Linux kernel history seems to use at least 12, for example.\n>>\n>> I believe that the \"one of the established formats\" comes from a\n>> \"git one\" alias I published somewhere long time ago, that did\n>> something like this:\n>>\n>>   git show -s --abbrev=8 --pretty='format:%h (%s, %ai' \"$@\" |\n>>   sed -e 's/ [012][0-9]:[0-5][0-9]:[0-5][0-9] \n>> [-+][0-9][0-9][0-9][0-9]$/)/'\n>>\n>> where the combination of --abbrev=8 and format:%h asks for a unique\n>> abbreviation that is at least 8 hexdigits long but can use more than\n>> 8 if it is not long enough to uniquely identify the given commit.\n>\n> For the intended use case of this feature (referring to earlier \n> commits\n> in commit messages), guaranteeing uniqueness isn't sufficiant either.\n> What is unique at the time of creating the commit might no longer be\n> unique a few years later.\n\nThis is true, but the purpose of the format with the summary text and \ndate\nis exactly to make it redundant enough that the hash doesn't have to be \nunique\nin eternity.\n\n> So one strategy would be to add one or two digits to what %h returns, \n> to\n> give some future leeway; or rely on the user to configure core.abbrev\n> appropriatly for their project; or just make the hard-coded value\n> configurable, as Hannes suggests.\n>\n> FWIW, a discussion of this that I find useful can be found here:\n> <http://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/>.\n"},{"id":"266229","messageId":"20150717092251.GB5916@iris.ozlabs.ibm.com","threadId":"39860","inReplyTo":"1437060565-4716-1-git-send-email-dev+git@drbeat.li","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2015-07-17T09:22:51Z","receivedAt":"2015-07-17T09:22:51Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Thu, Jul 16, 2015 at 05:29:25PM +0200, Beat Bolli wrote:\n> When referring to earlier commits in commit messages or other text, one\n> of the established formats is\n> \n>     <abbrev-sha> (\"<summary>\", <author-date>)\n> \n> Add a \"Copy commit summary\" command to the context menu that puts this\n> text for the currently selected commit on the clipboard. This makes it\n> easy for our users to create well-formatted commit references.\n\nI really like this idea, but as others have noted, 8 characters may\nnot be the right choice for the SHA1 length in all cases.\n\nWe have an item in the preferences menu to control the SHA1 length\nthat is automatically selected when going to a new commit.  It's\nstored in the variable $autosellen.  That seems like it would be a\nreasonable choice for the SHA1 length to use here.  The only possible\nproblem is that it defaults to 40 and so might give an overly long\nresult for some users.  Maybe you could use $autosellen but limit it\nto at most 12 or 16 or something like that.\n\nPaul.\n"},{"id":"266241","messageId":"xmqqvbdi3ipb.fsf@gitster.dls.corp.google.com","threadId":"39860","inReplyTo":"20150717092251.GB5916@iris.ozlabs.ibm.com","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-17T15:30:24Z","receivedAt":"2015-07-17T15:30:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n> We have an item in the preferences menu to control the SHA1 length\n> that is automatically selected when going to a new commit.  It's\n> stored in the variable $autosellen.  That seems like it would be a\n> reasonable choice for the SHA1 length to use here.\n\nReusing a configuration that is used to control something similar\nsounds sensible to me.\n\n> The only possible\n> problem is that it defaults to 40 and so might give an overly long\n> result for some users.  Maybe you could use $autosellen but limit it\n> to at most 12 or 16 or something like that.\n\nHow is the thing that is \"automatically selected when going to a new\ncommit\" used by the end user?  What is the reason why people may\nwant to configure it?  I understand that this is the string that\ngoes into the selection buffer, so presumably people are using this\nselection to paste elsewhere?  If so, that sounds like very similar\nto Beat's use case---perhaps if 40 is too long for Beat's use case\nas a sensible default, then it is also too long for its original use\ncase?\n\nOr do you expect it to be common to want to use autosellen set to 40\nand Beat's abbrev len set to much shorter, e.g. 16?  If so they may\ndeserve two different settings, with different defaults.\n\nArtificially limiting it to 12 or 16 does not sound all that\nsensible, though.\n\nThanks.\n"},{"id":"266327","messageId":"20150718122325.GA6817@yogo.paulus.ozlabs.org","threadId":"39860","inReplyTo":"xmqqvbdi3ipb.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2015-07-18T12:23:25Z","receivedAt":"2015-07-18T12:23:25Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Fri, Jul 17, 2015 at 08:30:24AM -0700, Junio C Hamano wrote:\n> Paul Mackerras <paulus@samba.org> writes:\n> \n> > We have an item in the preferences menu to control the SHA1 length\n> > that is automatically selected when going to a new commit.  It's\n> > stored in the variable $autosellen.  That seems like it would be a\n> > reasonable choice for the SHA1 length to use here.\n> \n> Reusing a configuration that is used to control something similar\n> sounds sensible to me.\n> \n> > The only possible\n> > problem is that it defaults to 40 and so might give an overly long\n> > result for some users.  Maybe you could use $autosellen but limit it\n> > to at most 12 or 16 or something like that.\n> \n> How is the thing that is \"automatically selected when going to a new\n> commit\" used by the end user?  What is the reason why people may\n> want to configure it?  I understand that this is the string that\n> goes into the selection buffer, so presumably people are using this\n> selection to paste elsewhere?  If so, that sounds like very similar\n> to Beat's use case---perhaps if 40 is too long for Beat's use case\n> as a sensible default, then it is also too long for its original use\n> case?\n\nIt's used for pasting into commit messages and emails, and it's used\nfor pasting onto the command line when typing git commands.  For the\nsecond, the length doesn't matter; the limit was added for the first\ncase.\n\n> Or do you expect it to be common to want to use autosellen set to 40\n> and Beat's abbrev len set to much shorter, e.g. 16?  If so they may\n> deserve two different settings, with different defaults.\n\nI would think that if $autosellen is 40 it's almost certainly because\nthe user hasn't found that control in the preferences window. :)\n\n> Artificially limiting it to 12 or 16 does not sound all that\n> sensible, though.\n\nAdding --abbrev=$autosellen if $autosellen is not 40 sounds like it\nwould do what we want.\n\nPaul.\n"},{"id":"266328","messageId":"55AA4A6E.9000301@drbeat.li","threadId":"39860","inReplyTo":"20150718122325.GA6817@yogo.paulus.ozlabs.org","subject":"Re: [PATCH v2] gitk: Add a \"Copy commit summary\" command","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2015-07-18T12:45:34Z","receivedAt":"2015-07-18T12:45:34Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"On 18.07.15 14:23, Paul Mackerras wrote:\n> On Fri, Jul 17, 2015 at 08:30:24AM -0700, Junio C Hamano wrote:\n>> Paul Mackerras <paulus@samba.org> writes:\n>>\n>>> We have an item in the preferences menu to control the SHA1 length\n>>> that is automatically selected when going to a new commit.  It's\n>>> stored in the variable $autosellen.  That seems like it would be a\n>>> reasonable choice for the SHA1 length to use here.\n>>\n>> Reusing a configuration that is used to control something similar\n>> sounds sensible to me.\n>>\n>>> The only possible\n>>> problem is that it defaults to 40 and so might give an overly long\n>>> result for some users.  Maybe you could use $autosellen but limit it\n>>> to at most 12 or 16 or something like that.\n>>\n>> How is the thing that is \"automatically selected when going to a new\n>> commit\" used by the end user?  What is the reason why people may\n>> want to configure it?  I understand that this is the string that\n>> goes into the selection buffer, so presumably people are using this\n>> selection to paste elsewhere?  If so, that sounds like very similar\n>> to Beat's use case---perhaps if 40 is too long for Beat's use case\n>> as a sensible default, then it is also too long for its original use\n>> case?\n> \n> It's used for pasting into commit messages and emails, and it's used\n> for pasting onto the command line when typing git commands.  For the\n> second, the length doesn't matter; the limit was added for the first\n> case.\n> \n>> Or do you expect it to be common to want to use autosellen set to 40\n>> and Beat's abbrev len set to much shorter, e.g. 16?  If so they may\n>> deserve two different settings, with different defaults.\n> \n> I would think that if $autosellen is 40 it's almost certainly because\n> the user hasn't found that control in the preferences window. :)\n> \n>> Artificially limiting it to 12 or 16 does not sound all that\n>> sensible, though.\n> \n> Adding --abbrev=$autosellen if $autosellen is not 40 sounds like it\n> would do what we want.\n\nThat's exactly what I did in v4 of the patch:\nhttp://article.gmane.org/gmane.comp.version-control.git/274161\n\nThanks,\nBeat\n"}]}