{"thread":{"id":"3294","subject":"[PATCH] Munge ChangeLog-style commit messages, and grab author name and email.","startedAt":"2006-02-11T01:19:13Z","lastAt":"2006-02-11T05:39:16Z","messageCount":2,"participants":["Carl Worth","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15888","messageId":"87slqqvgj2.wl%cworth@cworth.org","threadId":"3294","inReplyTo":null,"subject":"[PATCH] Munge ChangeLog-style commit messages, and grab author name and email.","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-11T01:19:13Z","receivedAt":"2006-02-11T01:19:13Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"The cairo project has been using ChangeLog-style commit messages, such as:\n\n\t2006-01-18  Carl Worth  <cworth@cworth.org>\n\n\t\t* src/cairo-pdf-surface.c: (cairo_pdf_surface_create_for_stream),\n\t\t(cairo_pdf_surface_create): Fix compilation-breaking typo.\n\nThis patch recognizes that style and munges it up into:\n\n\tFix compilation-breaking typo.\n\nwhich results in a much more useful headline within git.\n\nIt also grabs the name and email address from the first line and\ncommits with those as GIT_AUTHOR_NAME and GIT_AUTHOR_MAIL.\n\nIt would probably make sense to hide all this munging behind an\nappropriate command-line parameter, but I'm offering this up as is in\ncase it's useful for anyone with similar commit messages.\n\nSigned-off-by: Carl Worth <cworth@cworth.org>\nSigned-off-by: Keith Packard <keithp@keithp.com>\n\n---\n\n git-cvsimport.perl |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 71 insertions(+), 0 deletions(-)\n\n2f2002fe619c45cb1be1c0f063416ede242f3552\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 00fc3ba..6b63aa2 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -658,6 +658,12 @@ my $commit = sub {\n \t\t\t}\n \t\t}\n \n+\t\t# Look for name and email from ChangeLog-style commit message\n+\t\tif ($logmsg =~ /^\\s*\\d\\d\\d\\d-\\d\\d-\\d\\d\\s*(.*)\\s*<(.*)>/) {\n+\t\t    $author_name = $1;\n+\t\t    $author_email = $2;\n+\t\t}\n+\n \t\texec(\"env\",\n \t\t\t\"GIT_AUTHOR_NAME=$author_name\",\n \t\t\t\"GIT_AUTHOR_EMAIL=$author_email\",\n@@ -673,8 +679,73 @@ my $commit = sub {\n \n \t# compatibility with git2cvs\n \tsubstr($logmsg,32767) = \"\" if length($logmsg) > 32767;\n+\n+\t# We do a bunch of munging on the log message here,\n+\t# particularly for logs that are formatted in a ChangeLog\n+\t# style.\n+\n+\tmy $origlog = $logmsg;\n+\n+\t# Kill initial date/name stamp: YYYY-MM-DD First Last <email@example.com>\n+\n+\t$logmsg =~ s|^\\s*\\d\\d*-\\d\\d*-\\d\\d*\\s*[^<\\n]*<[^>\\n]*>\\s*$|* \\n|mg;\n+\n+\t# Strip out nickle version numbers\n+\t$logmsg =~ s|^(version )?2.\\d\\d*$||mg;\n+\n+\t# Remove initial space for each line\n+\t$logmsg =~ s|^[ \\t]+||mg;\n+\n+\t# Collapse space sequences\n+\t$logmsg =~ s|[ \\t]+| |g;\n+\n+\t# Un-fold paragraphs\n+\t$logmsg =~ s|([^\\n])\\n([^*+\\-\\n])|$1 $2|g;\n+\n+\tmy @lines = split (/\\n/, $logmsg);\n+\t\n+\t$logmsg = \"\";\n+\n+\tmy $reviews = \"\";\n+\n+\tforeach my $line (@lines) {\n+\t\t# Pull out any reviewed-by name\n+\t\tif ($line =~ /^reviewed by:\\s*/i) {\n+\t\t\tif ($line !~ /<delete if not using/) {\n+\t\t\t\t$reviews = $reviews . \"\\n\" . $line;\n+\t\t\t}\n+\t\t} else { \n+\t\t        # find lines begining with '*'\n+\t\t\tif ($line =~ s/^\\*\\s\\s*//) {\n+\t\t\t\t# strip off filenames\n+\t\t\t        while ($line =~ s/^[^ :,]*([,:]| (?=\\())\\s*// ) {\n+\t\t\t\t}\n+\t\t\t\t# strip off function names\n+\t\t\t\twhile ($line =~ s/^\\([^)]*\\)[,:]*\\s*// ) {\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\t$logmsg = $logmsg . $line . \"\\n\";\n+\t\t}\n+\t}\n+\t$logmsg = $logmsg . $reviews;\n+\n+\t# Trim initial newlines\n+\t$logmsg =~ s|^\\n+||;\n+\n+\t# Remove initial space for each line\n+\t$logmsg =~ s|^[ \\t]+||mg;\n+\n+\t# Collapse space sequences\n+\t$logmsg =~ s|[ \\t]+| |g;\n+\n+\t# collapse sequences of newlines\n+\t$logmsg =~ s/\\n\\n*/\\n/g;\n+\n+\t# Remove trailing whitespace\n \t$logmsg =~ s/[\\s\\n]+\\z//;\n \n+#\tprint \"<<<< Original\\n$origlog\\n---- Rewritten\\n$logmsg\\n<<<<\\n\";\n+\t\n \tif (@skipped) {\n \t    $logmsg .= \"\\n\\n\\nSKIPPED:\\n\\t\";\n \t    $logmsg .= join(\"\\n\\t\", @skipped) . \"\\n\";\n-- \n1.1.6.g9da5\n"},{"id":"15905","messageId":"7v3biqpi7v.fsf@assigned-by-dhcp.cox.net","threadId":"3294","inReplyTo":"87slqqvgj2.wl%cworth@cworth.org","subject":"Re: [PATCH] Munge ChangeLog-style commit messages, and grab author name and email.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T05:39:16Z","receivedAt":"2006-02-11T05:39:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Worth <cworth@cworth.org> writes:\n\n> The cairo project has been using ChangeLog-style commit messages, such as:\n>\n> \t2006-01-18  Carl Worth  <cworth@cworth.org>\n>\n> \t\t* src/cairo-pdf-surface.c: (cairo_pdf_surface_create_for_stream),\n> \t\t(cairo_pdf_surface_create): Fix compilation-breaking typo.\n>\n> This patch recognizes that style and munges it up into:\n>\n> \tFix compilation-breaking typo.\n>\n> which results in a much more useful headline within git.\n\nI welcome discussion on this patch, but as its in current shape,\nit looks a bit too specific to one particular style.\n\nI think the one you quoted above is the GNU official style which\nis used in many projects.  I suspect your patch would help\npeople converting other projects as well.  Having said that, as\nyou said it yourself, it would make more sense to make a more\ngeneralized log munging interface.\n\nEven though there might be many different schools of style,\nhopefully each project consistently sticks to one style.  Log\nmessages out of SVN repository tend to have their own styles.\nWe could define a common command line option, say --log-filter,\nthat are available across importers.  E.g.\n\n\tgit-cvsimport --log-filter=gnu-log-style\n\tgit-svnimport --log-filter=gnu-log-style\n\n'gnu-log-style' would be the massager you have hardcoded in the\npatch, but made into a traditional UNIXy filter.  We could\ncreate contrib/commit-filters directory in git.git repository\nand ship collections of such log massagers.\n"}]}