Hi, On Sun, 22 Jul 2007, Jon Smirl wrote: > On 7/22/07, Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote: > > But still, I think that it would be much better not to put this into Git. > > We do have diff gitattributes now, so that you can roll your own diff for > > specific files, but I still think that this is more a task for a > > standalone perl script. Possibly being called from filter-branch to be > > done with the conversion once and for all times. > > I can provide sample diffs if you want something to play with. As you already did, this is my attempt at a perl script... Feel free to bash my Perl capabilities, or to correct it... 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 $_; } } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html