{"thread":{"id":"10594","subject":"[PATCH] New script: git-changelog.perl","startedAt":"2007-11-02T15:55:24Z","lastAt":"2007-11-02T18:53:31Z","messageCount":4,"participants":["Ronald Landheer-Cieslak","Jakub Narebski","Johannes Schindelin","Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58002","messageId":"67837cd60711020855v5badf7a6o9b777f339df070f@mail.gmail.com","threadId":"10594","inReplyTo":null,"subject":"[PATCH] New script: git-changelog.perl","fromName":"Ronald Landheer-Cieslak","fromEmail":"ronald@landheer-cieslak.com","sentAt":"2007-11-02T15:55:24Z","receivedAt":"2007-11-02T15:55:24Z","isPatch":true,"sender":{"key":"ronald@landheer-cieslak.com","avatar":"https://gravatar.com/avatar/5acb7195551996209b4511ffbbbcf8e13389789352b1a5173e7d6cbee734b53f?d=mp&s=160"},"body":"Hello all,\n\nI've written a little script that will format the changes as reported\nby git-log in a ChangeLog-like format. Entries look like this:\n<date>\\t<author>\\n\\t<sha1>: <subject>\n\nAn example taken from Gits own recent history:\n\n2007-10-30      Junio C Hamano\n        9c51414: Merge branch 'maint' into HEAD\n        7eedc1c: Merge branch 'nd/worktree' into HEAD\n        9725bb8: Merge branch 'cc/skip' into HEAD\n        7ae4dd0: Merge branch 'jk/send-pack' into HEAD\n        7e9a464: Merge branch 'lt/rename' into HEAD\n        6beb669: Merge branch 'jn/web' into HEAD\n        791e421: Merge branch 'ds/gitweb' into HEAD\n        5153399: Merge branch 'js/rebase' into HEAD\n        0bdb5af: Update GIT 1.5.3.5 Release Notes\n\n2007-10-30      Gerrit Pape\n        fee9832: No longer install git-svnimport, move to contrib/examples\n\nI intend to use it for releases of my software, and I though others\nmight like it as well.\n\nI haven't implemented any help yet, but if any-one would like some\ndocumentation, I'll be glad to provide it.\n\nrlc\n\ndiff --git a/Makefile b/Makefile\nindex 71479a2..cf2cb32 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -226,7 +226,7 @@ SCRIPT_PERL = \\\n        git-add--interactive.perl \\\n        git-archimport.perl git-cvsimport.perl git-relink.perl \\\n        git-cvsserver.perl git-remote.perl git-cvsexportcommit.perl \\\n-       git-send-email.perl git-svn.perl\n+       git-send-email.perl git-svn.perl git-changelog.perl\n\n SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \\\n          $(patsubst %.perl,%,$(SCRIPT_PERL)) \\\ndiff --git a/git-changelog.perl b/git-changelog.perl\nnew file mode 100755\nindex 0000000..bffa1ab\n--- /dev/null\n+++ b/git-changelog.perl\n@@ -0,0 +1,68 @@\n+#!/usr/bin/perl -w\n+\n+use strict;\n+\n+sub fetch_log {\n+       my $command='git log --pretty=format:\"%ai|%an|%h|%s\" ';\n+       foreach (@_) {\n+               $command .= ' ' . $_;\n+       }\n+       $command .= \" |\";\n+       my $fh;\n+       open $fh, $command\n+               or die \"Failed to fetch logs\";\n+       # logs are presented as lines in which fields are separated by pipes.\n+       # the fields are the date in ISO format (so the date as we\nwant it extends to the\n+       # first space), the name of the author, the abbreviated SHA1\nhash and the subject line\n+       my $date_time;\n+       my $date;\n+       my $cruft;\n+       my $author;\n+       my $hash;\n+       my $subject;\n+       my $prev_date=\"\";\n+       my @cache; # a cache of the changes for the current date (i.e.\nwhile $prev_date eq $date)\n+       my %entry; # a cache entry; $entry{'author'} is the entry and\n@$entry{'changes'} are the changes for the author in question\n+       while (<$fh>) {\n+               ($date_time, $author, $hash, $subject) = split(/\\|/);\n+               ($date, $cruft) = split(/\\s/, $date_time, 2);\n+               chomp $author;\n+\n+               if ($date ne $prev_date)\n+               {\n+                       foreach (@cache)\n+                       {\n+                               # print out the line with the date and\nthe author\n+                               my $changes = $_->{'changes'};\n+                               print \"\\n\" . $prev_date . \"\\t\" .\n$_->{'author'} . \"\\n\" if ($#{$changes} != -1);\n+                               foreach (@{$changes})\n+                               {\n+                                       print \"\\t\" . $_->{'hash'} . ':\n' . $_->{'subject'};\n+                               }\n+                       }\n+                       $prev_date = $date;\n+                       @cache = ();\n+               }\n+               # try to find an entry with the same author in the cache\n+               my $found = -1;\n+               my $i;\n+               for ($i = 0; $i <= $#cache && $found == -1; $i++)\n+               {\n+                       if ($cache[$i]->{'author'} eq $author)\n+                       {\n+                               $found = $i;\n+                       }\n+               }\n+               if ($found == -1)\n+               {\n+                       my $changes = ();\n+                       push @cache, { 'author', $author, 'changes', $changes };\n+                       $found = $#cache;\n+               }\n+               push @{$cache[$found]->{'changes'}}, { 'hash', $hash,\n'subject', $subject };\n+       }\n+}\n+\n+fetch_log @ARGV;\n+\n+\n\n\n\n-- \nRonald Landheer-Cieslak\nSoftware Architect\nhttp://www.landheer-cieslak.com/\nNew White Paper: \"Three Good Reasons to Plan Ahead\"\n"},{"id":"58008","messageId":"fgflce$aea$1@ger.gmane.org","threadId":"10594","inReplyTo":"67837cd60711020855v5badf7a6o9b777f339df070f@mail.gmail.com","subject":"Re: [PATCH] New script: git-changelog.perl","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-02T17:07:57Z","receivedAt":"2007-11-02T17:07:57Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"[Cc: Ronald Landheer-Cieslak <ronald@landheer-cieslak.com>, \n git@vger.kernel.org]\n\nRonald Landheer-Cieslak wrote:\n\n> I've written a little script that will format the changes as reported\n> by git-log in a ChangeLog-like format. Entries look like this:\n> <date>\\t<author>\\n\\t<sha1>: <subject>\n\nHow it compares to existing git2cl tool?:\n  http://josefsson.org/git2cl/\n  http://git.or.cz/gitwiki/InterfacesFrontendsAndTools\n\nBTW. Do anyone has idea why on above wiki page table of contents does not\ndisplay some sections at all?\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"58015","messageId":"Pine.LNX.4.64.0711021821410.4362@racer.site","threadId":"10594","inReplyTo":"67837cd60711020855v5badf7a6o9b777f339df070f@mail.gmail.com","subject":"Re: [PATCH] New script: git-changelog.perl","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-02T18:27:23Z","receivedAt":"2007-11-02T18:27:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 2 Nov 2007, Ronald Landheer-Cieslak wrote:\n\n> I've written a little script that will format the changes as reported\n> by git-log in a ChangeLog-like format.\n\nJakub already commented on the availability of git2cl, but I thought I'd \nclarify: once upon a time I even wrote some builtin to perform that \ntransformation, and it was met with unilateral disgus^Wagreement not to \ninclude it into core git.\n\nTherefore I think it would be sanest to enhance git2cl until it does what \nyou want to do.\n\nCiao,\nDscho\n"},{"id":"58018","messageId":"alpine.LFD.0.9999.0711021447510.21255@xanadu.home","threadId":"10594","inReplyTo":"Pine.LNX.4.64.0711021821410.4362@racer.site","subject":"Re: [PATCH] New script: git-changelog.perl","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-02T18:53:31Z","receivedAt":"2007-11-02T18:53:31Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Fri, 2 Nov 2007, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Fri, 2 Nov 2007, Ronald Landheer-Cieslak wrote:\n> \n> > I've written a little script that will format the changes as reported\n> > by git-log in a ChangeLog-like format.\n> \n> Jakub already commented on the availability of git2cl, but I thought I'd \n> clarify: once upon a time I even wrote some builtin to perform that \n> transformation, and it was met with unilateral disgus^Wagreement not to \n> include it into core git.\n> \n> Therefore I think it would be sanest to enhance git2cl until it does what \n> you want to do.\n\nThe contrib directory is certainly a good place for such scripts as \nwell.\n\n\nNicolas\n"}]}