{"thread":{"id":"10599","subject":"[PATCH] New script: git-changelog.perl - revised","startedAt":"2007-11-02T20:03:27Z","lastAt":"2007-11-03T14:58:48Z","messageCount":5,"participants":["Ronald Landheer-Cieslak","Andreas Ericsson","Johannes Schindelin","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58028","messageId":"67837cd60711021303q488e0873lea363b93fc90d591@mail.gmail.com","threadId":"10599","inReplyTo":null,"subject":"[PATCH] New script: git-changelog.perl - revised","fromName":"Ronald Landheer-Cieslak","fromEmail":"ronald@landheer-cieslak.com","sentAt":"2007-11-02T20:03:27Z","receivedAt":"2007-11-02T20:03:27Z","isPatch":true,"sender":{"key":"ronald@landheer-cieslak.com","avatar":"https://gravatar.com/avatar/5acb7195551996209b4511ffbbbcf8e13389789352b1a5173e7d6cbee734b53f?d=mp&s=160"},"body":"I just noticed that I'd been sending personal replies to each and\nevery one of the replies I got - sorry about that.\n\nAnyway, after Nicolas' suggestion, I moved the script into the contrib\ndirectory and removed it from the Makefile, having the following patch\nas net effect.\nThis is also available through git at\ngit://vlinder.landheer-cieslak.com/git/git.git#topic/git-log-changelog\n\nAs for difference wrt git2cl:\n* less complicated\n* less dependencies\n* short hash for the commits are output in the change log\n* git-changelog calls git-log with the proper parameters itself (no\nneed for the user to call it with a given set of parameters).\n\nrlc\n\ndiff --git a/contrib/git-changelog/git-changelog.perl\nb/contrib/git-changelog/git-changelog.perl\nnew file mode 100755\nindex 0000000..bffa1ab\n--- /dev/null\n+++ b/contrib/git-changelog/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":"58083","messageId":"472C3309.70109@op5.se","threadId":"10599","inReplyTo":"67837cd60711021303q488e0873lea363b93fc90d591@mail.gmail.com","subject":"Re: [PATCH] New script: git-changelog.perl - revised","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-11-03T08:36:25Z","receivedAt":"2007-11-03T08:36:25Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Ronald Landheer-Cieslak wrote:\n>\n> This is also available through git at\n> git://vlinder.landheer-cieslak.com/git/git.git#topic/git-log-changelog\n> \n\nThis mode of specifying a repository + branch was just thoroughly shot\ndown in a list discussion, and git certainly doesn't grok it. I'd be a\nhappier fella if you didn't use it.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"58132","messageId":"67837cd60711030646p6d7dc8e3t8a5f5f336e8bbad6@mail.gmail.com","threadId":"10599","inReplyTo":"472C3309.70109@op5.se","subject":"Re: [PATCH] New script: git-changelog.perl - revised","fromName":"Ronald Landheer-Cieslak","fromEmail":"ronald@landheer-cieslak.com","sentAt":"2007-11-03T13:46:27Z","receivedAt":"2007-11-03T13:46:27Z","isPatch":true,"sender":{"key":"ronald@landheer-cieslak.com","avatar":"https://gravatar.com/avatar/5acb7195551996209b4511ffbbbcf8e13389789352b1a5173e7d6cbee734b53f?d=mp&s=160"},"body":"On Nov 3, 2007 4:36 AM, Andreas Ericsson <ae@op5.se> wrote:\n> Ronald Landheer-Cieslak wrote:\n> >\n> > This is also available through git at\n> > git://vlinder.landheer-cieslak.com/git/git.git#topic/git-log-changelog\n> >\n>\n> This mode of specifying a repository + branch was just thoroughly shot\n> down in a list discussion, and git certainly doesn't grok it. I'd be a\n> happier fella if you didn't use it.\n>\nIs there a canonical way to specify both the location and the branch\nin one shot, then? I must admit that this is the way I've always seen\nit specified, so I assumed that this is the way it was done\n\"canonically\". If it isn't, please forgive my ignorance.\n\nrlc\n\n\n-- \nRonald Landheer-Cieslak\nSoftware Architect\nhttp://www.landheer-cieslak.com/\nNew White Paper: \"Three Good Reasons to Plan Ahead\"\n"},{"id":"58135","messageId":"Pine.LNX.4.64.0711031357510.4362@racer.site","threadId":"10599","inReplyTo":"67837cd60711030646p6d7dc8e3t8a5f5f336e8bbad6@mail.gmail.com","subject":"Re: [PATCH] New script: git-changelog.perl - revised","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-03T13:58:33Z","receivedAt":"2007-11-03T13:58:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 3 Nov 2007, Ronald Landheer-Cieslak wrote:\n\n> On Nov 3, 2007 4:36 AM, Andreas Ericsson <ae@op5.se> wrote:\n> > Ronald Landheer-Cieslak wrote:\n> > >\n> > > This is also available through git at\n> > > git://vlinder.landheer-cieslak.com/git/git.git#topic/git-log-changelog\n> > >\n> >\n> > This mode of specifying a repository + branch was just thoroughly shot\n> > down in a list discussion, and git certainly doesn't grok it. I'd be a\n> > happier fella if you didn't use it.\n> >\n> Is there a canonical way to specify both the location and the branch\n> in one shot, then?\n\nYes.  Create a repository containing only that branch, as \"master\", and \npoint people to that repository.\n\nHth,\nDscho\n"},{"id":"58142","messageId":"20071103145848.GA3175@steel.home","threadId":"10599","inReplyTo":"67837cd60711030646p6d7dc8e3t8a5f5f336e8bbad6@mail.gmail.com","subject":"Re: [PATCH] New script: git-changelog.perl - revised","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-11-03T14:58:48Z","receivedAt":"2007-11-03T14:58:48Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Ronald Landheer-Cieslak, Sat, Nov 03, 2007 14:46:27 +0100:\n> On Nov 3, 2007 4:36 AM, Andreas Ericsson <ae@op5.se> wrote:\n> > Ronald Landheer-Cieslak wrote:\n> > >\n> > > This is also available through git at\n> > > git://vlinder.landheer-cieslak.com/git/git.git#topic/git-log-changelog\n> > >\n> >\n> > This mode of specifying a repository + branch was just thoroughly shot\n> > down in a list discussion, and git certainly doesn't grok it. I'd be a\n> > happier fella if you didn't use it.\n> >\n> Is there a canonical way to specify both the location and the branch\n> in one shot, then? ...\n\nSomething like this:\n\n    Please fetch from\n\n    git://vlinder.landheer-cieslak.com/git/git.git topic/git-log-changelog\n\nIf one uses git-fetch the result will be in FETCH_HEAD, a pull will\nmerge it nicely with the commit message like:\n\n    \"Merge branch 'topic/git-log-changelog' of git://vlinder.landheer-cieslak.com/git/git\"\n\nwhich fits, I believe.\n"}]}