git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git help for kernel archeology, suppress diffs caused by CVS keyword expansion

From
Jon Smirl <jonsmirl@gmail.com>
Date
Jul 22, 2007, 23:45 UTC
Message-ID
<9e4733910707221645x21d74e70y3c43bc8c02a9d4ca@mail.gmail.com>
In-Reply-To
<Pine.LNX.4.64.0707222238180.14781@racer.site>
On 7/22/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> As you already did, this is my attempt at a perl script...  Feel free to
> bash my Perl capabilities, or to correct it...

I don't really know Perl but Perl is probably a better language for this. I was doing it in C. This doesn't run on the two full kernel samples I sent you. That's the problem I was having, I can catch 95% of the expanded keywords with my program but I have to touch up 5% by hand. I'll stare at this and see if I can increase my understanding of Perl.

Show 94 quoted lines
>
> Ciao,
> Dscho
>
> -- snipsnap --
> #!/usr/bin/perl
>
> sub init_hunk {
>         $_ = $_[0];
>         $current_hunk = "";
>         $current_hunk_header = $_;
>         ($start_minus, $dummy, $start_plus, $dummy) =
>                 /^\@\@ -(\d+)(,\d+|) \+(\d+)(,\d+|) \@\@/;
>         $plus = $minus = $space = 0;
>         $skip_logs = 0;
> }
>
> sub flush_hunk {
>         if ($plus > 0 || $minus > 0) {
>                 if ($current_file ne "") {
>                         print $current_file;
>                         $current_file = "";
>                 }
>                 $minus += $space;
>                 $plus += $space;
>                 print "\@\@ -$start_minus,$minus "
>                         . "+$start_plus,$plus \@\@\n";
>                 print $current_hunk;
>         }
> }
>
> sub check_file {
>         $_ = $_[0];
>         $current_file = $_;
>         while (<>) {
>                 if (/^\@\@/) {
>                         last;
>                 }
>                 $current_file .= $_;
>         }
>
>         init_hunk $_;
>
>         # check hunks
>         while (<>) {
>                 if ($skip_logs && /^\+ *\*/) {
>                         # do nothing
>                 } elsif (/^\@\@.*/) {
>                         flush_hunk;
>                         init_hunk $_;
>                 } elsif (/^diff/) {
>                         flush_hunk;
>                         return;
>                 } elsif (/^-.*\$(Id|Revision|Author|Date).*\$/) {
>                         $key = $1;
>                         s/^-/ /;
>                         $current_hunk .= $_;
>                         $space++;
>                         $_ = <>;
>                         if (!/\+.*\$Id.*\$/) {
>                                 die "Expected some changed \$$key line: $_";
>                         }
>                         $skip_logs = 0;
>                 } elsif (/^ .*\$Log.*\$/) {
>                         $current_hunk .= $_;
>                         $space++;
>                         $skip_logs++;
>                 } elsif (/^ /) {
>                         $current_hunk .= $_;
>                         $space++;
>                         $skip_logs = 0;
>                 } elsif (/^\+/) {
>                         $current_hunk .= $_;
>                         $plus++;
>                 } elsif (/^-/) {
>                         $current_hunk .= $_;
>                         $minus++;
>                         $skip_logs = 0;
>                 } else {
>                         die "Unexpected line: $_";
>                 }
>         }
> }
>
> while (<>) {
>         if (/^diff/) {
>                 do {
>                         check_file $_;
>                 } while(/^diff/);
>         } else {
>                 printf $_;
>         }
> }
>
-- 
Jon Smirl
jonsmirl@gmail.com
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 24 in “Git help for kernel archeology, suppress diffs caused by CVS keyword expansion”
  1. Jon SmirlJul 22, 2007
  2. Johannes SchindelinJul 22, 2007
  3. Jon SmirlJul 22, 2007
  4. Johannes SchindelinJul 22, 2007
  5. Jon SmirlJul 22, 2007
  6. Johannes SchindelinJul 22, 2007
  7. Jon SmirlJul 22, 2007
  8. Johannes SchindelinJul 22, 2007
  9. Jon SmirlJul 23, 2007
  10. Johannes SchindelinJul 23, 2007
  11. Jon SmirlJul 23, 2007
  12. Simon 'corecode' SchubertJul 23, 2007
  13. Johannes SchindelinJul 23, 2007
  14. Jon SmirlJul 24, 2007
  15. Jon SmirlJul 24, 2007
  16. Johannes SchindelinJul 24, 2007
  17. Jakub NarebskiJul 24, 2007
  18. Johannes SchindelinJul 24, 2007
  19. Jon SmirlJul 24, 2007
  20. Linus TorvaldsJul 22, 2007
  21. Jon SmirlJul 22, 2007
  22. Linus TorvaldsJul 22, 2007
  23. David KastrupJul 22, 2007
  24. Jan EngelhardtJul 22, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.