{"thread":{"id":"37324","subject":"Re: [PATCH] checkpatch: Add test for commit id formatting style in commit log","startedAt":"2014-08-10T21:08:31Z","lastAt":"2014-08-10T21:41:37Z","messageCount":4,"participants":["Geert Uytterhoeven","Joe Perches","Andrew Morton"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"247563","messageId":"CAMuHMdV1TXLmuAofwrUuT-KKUfkEYdXsM34VRrfhB6FxXfdeeg@mail.gmail.com","threadId":"37324","inReplyTo":"1404338448.14741.8.camel@joe-AO725","subject":"Re: [PATCH] checkpatch: Add test for commit id formatting style in commit log","fromName":"Geert Uytterhoeven","fromEmail":"geert@linux-m68k.org","sentAt":"2014-08-10T21:08:31Z","receivedAt":"2014-08-10T21:08:31Z","isPatch":true,"sender":{"key":"geert@linux-m68k.org","avatar":"https://gravatar.com/avatar/8105b34f653a7b5b98e225e565b11ebcc762ad4ab1a9d905a4663db029a9e6bc?d=mp&s=160"},"body":"Hi Joe,\n\nOn Thu, Jul 3, 2014 at 12:00 AM, Joe Perches <joe@perches.com> wrote:\n> Commit logs have various forms of commit id references.\n>\n> Try to standardize on a 12 character long lower case\n> commit id along with a description of parentheses and\n> the quoted subject line\n>\n> ie: commit 0123456789ab (\"commit description\")\n\nNow this is in mainline, checkpatch starts complaining about my \"too long\"\n(40 chars) commit IDs in commit messages :-(\n\n40 chars may be too long (but it's quick to copy-and-paste, as \"git show\"\nshows that by default), but 12 sounds a bit short, as that's only 48 bits.\n\nAccording to the Birthday Paradox (en.wikipedia.org/wiki/Birthday_problem),\nthere's a probability of 50% of a collision if you use 48 bits IDs in a\nrepository with ca. 16 milion (2^24) objects. A Linux kernel repository\ncounts ca. 4 million objects, so we're getting close...\n\nSo soon we'll get \"error: short SHA1 is ambiguous\".\n\nBTW, is there actually an easy way to make \"git show\" show all options for\nan ambiguous SHA1?\n\nGr{oetje,eeting}s,\n\n                        Geert\n\n--\nGeert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org\n\nIn personal conversations with technical people, I call myself a hacker. But\nwhen I'm talking to journalists I just say \"programmer\" or something like that.\n                                -- Linus Torvalds\n"},{"id":"247564","messageId":"1407706081.4082.21.camel@joe-AO725","threadId":"37324","inReplyTo":"CAMuHMdV1TXLmuAofwrUuT-KKUfkEYdXsM34VRrfhB6FxXfdeeg@mail.gmail.com","subject":"Re: [PATCH] checkpatch: Add test for commit id formatting style in commit log","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2014-08-10T21:28:01Z","receivedAt":"2014-08-10T21:28:01Z","isPatch":true,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Sun, 2014-08-10 at 23:08 +0200, Geert Uytterhoeven wrote:\n> Hi Joe,\n\nHi Geert.\n\n> On Thu, Jul 3, 2014 at 12:00 AM, Joe Perches <joe@perches.com> wrote:\n> > Commit logs have various forms of commit id references.\n> >\n> > Try to standardize on a 12 character long lower case\n> > commit id along with a description of parentheses and\n> > the quoted subject line\n> >\n> > ie: commit 0123456789ab (\"commit description\")\n> \n> Now this is in mainline, checkpatch starts complaining about my \"too long\"\n> (40 chars) commit IDs in commit messages :-(\n> \n> 40 chars may be too long (but it's quick to copy-and-paste, as \"git show\"\n> shows that by default), but 12 sounds a bit short, as that's only 48 bits.\n\nRight now, this test allows 12 to 16 byte length commit ids\nwithout emitting a warning.\n\nAndrew wanted this test, I don't care how long the commit id\nis in the commit log.\n\n> According to the Birthday Paradox (en.wikiipedia.org/wiki/Birthday_problem),\n> there's a probability of 50% of a collision if you use 48 bits IDs in a\n> repository with ca. 16 milion (2^24) objects. A Linux kernel repository\n> counts ca. 4 million objects, so we're getting close...\n> \n> So soon we'll get \"error: short SHA1 is ambiguous\".\n> \n> BTW, is there actually an easy way to make \"git show\" show all options for\n> an ambiguous SHA1?\n\nNot so far as I know, but I'm nothing like a git expert.\n\nThe script I used before adding this to checkpatch was:\n\n$ cat format_commit.sh \n#!/bin/bash\n\nregex1=\"^error: short SHA1 $1 is ambiguous\\.\"\nregex2=\"fatal: ambiguous argument '$1': unknown revision or path not in the working tree\\.\"\n\ntmp=$(mktemp --tmpdir format_commit.XXXXXXXXXXXXX)\n\ngit log --format='%H (\"%s\")' -1 $1 > $tmp 2>&1\n\nread line < $tmp\n\nrm -f $tmp\n\nif [[ $line =~ $regex1 ]] ; then\n    echo \"checking commits $1...\"\n    git rev-list --remotes | grep -i \"^$1\" |\n    while read line ; do\n        git log --format='%H (\"%s\")' -1 $line | \n        echo \"commit $(cut -c 1-12,41-)\"\n    done\nelif [[ $line =~ $regex2 ]] ; then\n    echo \"No matching commit\"\n    exit 1\nelse\n    echo \"commit $(echo $line | cut -c1-12,41-)\"\nfi\n\nexit 0\n$\n\nso that using \"$ format_commit.sh 1234\" looks\nat _all_ the commit references by using git rev-list\nthen greps that output for the matches, but it is\ndarn slow...\n\n$ time ./format_commit.sh 1234\nchecking commits 1234...\ncommit 1234351cba95 (\"xfs: introduce xlog_copy_iovec\")\ncommit 1234471e2d11 (\"perf header: Fix numa topology printing\")\ncommit 1234f4bada54 (\"hwrng: Kconfig: remove dependency for atmel-rng driver\")\ncommit 12340313cf94 (\"MAINTAINERS: add new cgroup list to CC notice\")\ncommit 12346037a718 (\"UBIFS: dump more in the lprops debugging check\")\ncommit 12342c475f5d (\"iwlwifi: proper monitor support\")\ncommit 1234010684bb (\"Add notation that the Asus W5F laptop has a short cable instead of 80-wire.\")\ncommit 123411f2d0da (\"[CPUFREQ] dprintf format fixes in cpufreq/speedstep-centrino.c\")\n\nreal\t0m24.535s\nuser\t0m21.668s\nsys\t0m5.332s\n"},{"id":"247565","messageId":"20140810143500.2d556ae9.akpm@linux-foundation.org","threadId":"37324","inReplyTo":"1407706081.4082.21.camel@joe-AO725","subject":"Re: [PATCH] checkpatch: Add test for commit id formatting style in commit log","fromName":"Andrew Morton","fromEmail":"akpm@linux-foundation.org","sentAt":"2014-08-10T21:35:00Z","receivedAt":"2014-08-10T21:35:00Z","isPatch":true,"sender":{"key":"akpm@linux-foundation.org","avatar":null},"body":"On Sun, 10 Aug 2014 14:28:01 -0700 Joe Perches <joe@perches.com> wrote:\n\n> > On Thu, Jul 3, 2014 at 12:00 AM, Joe Perches <joe@perches.com> wrote:\n> > > Commit logs have various forms of commit id references.\n> > >\n> > > Try to standardize on a 12 character long lower case\n> > > commit id along with a description of parentheses and\n> > > the quoted subject line\n> > >\n> > > ie: commit 0123456789ab (\"commit description\")\n> > \n> > Now this is in mainline, checkpatch starts complaining about my \"too long\"\n> > (40 chars) commit IDs in commit messages :-(\n> > \n> > 40 chars may be too long (but it's quick to copy-and-paste, as \"git show\"\n> > shows that by default), but 12 sounds a bit short, as that's only 48 bits.\n> \n> Right now, this test allows 12 to 16 byte length commit ids\n> without emitting a warning.\n> \n> Andrew wanted this test, I don't care how long the commit id\n> is in the commit log.\n\nWell, I mainly wanted to stop having to add \"commit description\" when\npeople forget it.  The length check was perhaps a bit anal.  How about\nwe make it \"12 or more\"?\n"},{"id":"247568","messageId":"1407706897.4082.24.camel@joe-AO725","threadId":"37324","inReplyTo":"20140810143500.2d556ae9.akpm@linux-foundation.org","subject":"Re: [PATCH] checkpatch: Add test for commit id formatting style in commit log","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2014-08-10T21:41:37Z","receivedAt":"2014-08-10T21:41:37Z","isPatch":true,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Sun, 2014-08-10 at 14:35 -0700, Andrew Morton wrote:\n> On Sun, 10 Aug 2014 14:28:01 -0700 Joe Perches <joe@perches.com> wrote:\n> > > On Thu, Jul 3, 2014 at 12:00 AM, Joe Perches <joe@perches.com> wrote:\n> > > > Commit logs have various forms of commit id references.\n> > > >\n> > > > Try to standardize on a 12 character long lower case\n> > > > commit id along with a description of parentheses and\n> > > > the quoted subject line\n> > > >\n> > > > ie: commit 0123456789ab (\"commit description\")\n> > > \n> > > Now this is in mainline, checkpatch starts complaining about my \"too long\"\n> > > (40 chars) commit IDs in commit messages :-(\n> > > \n> > > 40 chars may be too long (but it's quick to copy-and-paste, as \"git show\"\n> > > shows that by default), but 12 sounds a bit short, as that's only 48 bits.\n> > \n> > Right now, this test allows 12 to 16 byte length commit ids\n> > without emitting a warning.\n> > \n> > Andrew wanted this test, I don't care how long the commit id\n> > is in the commit log.\n> \n> Well, I mainly wanted to stop having to add \"commit description\" when\n> people forget it.  The length check was perhaps a bit anal.  How about\n> we make it \"12 or more\"?\n\nFine by me, just change the 16 to 40\n---\n scripts/checkpatch.pl | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl\nindex 31a731e..b385bcb 100755\n--- a/scripts/checkpatch.pl\n+++ b/scripts/checkpatch.pl\n@@ -2133,7 +2133,7 @@ sub process {\n # Check for improperly formed commit descriptions\n \t\tif ($in_commit_log &&\n \t\t    $line =~ /\\bcommit\\s+[0-9a-f]{5,}/i &&\n-\t\t    $line !~ /\\b[Cc]ommit [0-9a-f]{12,16} \\(\"/) {\n+\t\t    $line !~ /\\b[Cc]ommit [0-9a-f]{12,40} \\(\"/) {\n \t\t\t$line =~ /\\b(c)ommit\\s+([0-9a-f]{5,})/i;\n \t\t\tmy $init_char = $1;\n \t\t\tmy $orig_commit = lc($2);\n@@ -2141,7 +2141,7 @@ sub process {\n \t\t\tmy $desc = 'commit description';\n \t\t        ($id, $desc) = git_commit_info($orig_commit, $id, $desc);\n \t\t\tERROR(\"GIT_COMMIT_ID\",\n-\t\t\t      \"Please use 12 to 16 chars for the git commit ID like: '${init_char}ommit $id (\\\"$desc\\\")'\\n\" . $herecurr);\n+\t\t\t      \"Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\\\"$desc\\\")'\\n\" . $herecurr);\n \t\t}\n \n # Check for added, moved or deleted files\n"}]}