git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Jon Smirl <jonsmirl@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Git help for kernel archeology, suppress diffs caused by CVS keyword expansion
Date: Mon, 23 Jul 2007 01:37:25 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707230136360.14781@racer.site> (raw)
In-Reply-To: <9e4733910707221711u6e965e6cr29e06fa8fb09165@mail.gmail.com>

Hi,

On Sun, 22 Jul 2007, Jon Smirl wrote:

> On 7/22/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > This doesn't run on the two full kernel samples I sent you.
> > 
> > You mean my script?  Or your C program?
> 
> Your script, I sent two big samples directly to you as attachments
> three hours ago.

Okay, I did not really test thoroughly, it seems.  Sorry.  Next try.

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;
	$key = 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 ($key && /^\+.*\$$key.*\$/) {
			# do nothing
		} elsif (/^\@\@.*/) {
			flush_hunk;
			init_hunk $_;
		} elsif (/^diff/) {
			flush_hunk;
			return;
		} elsif (/^-.*\$(Id|Revision|Author|Date).*\$/) {
			$key = $1;
			s/^-/ /;
			$current_hunk .= $_;
			$space++;
			$skip_logs = 0;
			$key = 0;
		} elsif (/^ .*\$Log.*\$/) {
			$current_hunk .= $_;
			$space++;
			$skip_logs = 1;
			$key = 0;
		} elsif (/^ /) {
			$current_hunk .= $_;
			$space++;
			$skip_logs = 0;
			$key = 0;
		} elsif (/^\+/) {
			$current_hunk .= $_;
			$plus++;
			$key = 0;
		} elsif (/^-/) {
			$current_hunk .= $_;
			$minus++;
			$skip_logs = 0;
			$key = 0;
		} elsif (/^\\/) {
			print $_;
		} else {
			die "Unexpected line: $_";
		}
	}
}

while (<>) {
	if (/^diff/) {
		do {
			check_file $_;
		} while(/^diff/);
	} else {
		printf $_;
	}
}

  reply	other threads:[~2007-07-23  0:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-22 18:48 Git help for kernel archeology, suppress diffs caused by CVS keyword expansion Jon Smirl
2007-07-22 19:00 ` Johannes Schindelin
2007-07-22 19:10   ` Jon Smirl
2007-07-22 19:15     ` Johannes Schindelin
2007-07-22 19:48       ` Jon Smirl
2007-07-22 21:39         ` Johannes Schindelin
2007-07-22 23:45           ` Jon Smirl
2007-07-22 23:50             ` Johannes Schindelin
2007-07-23  0:11               ` Jon Smirl
2007-07-23  0:37                 ` Johannes Schindelin [this message]
2007-07-23 14:44                   ` Jon Smirl
2007-07-23 15:11                     ` Simon 'corecode' Schubert
2007-07-23 20:11                     ` Johannes Schindelin
2007-07-24  0:43                       ` Jon Smirl
2007-07-24  1:06                         ` Jon Smirl
2007-07-24  1:16                         ` Johannes Schindelin
2007-07-24 10:16                           ` Jakub Narebski
2007-07-24 11:26                             ` Johannes Schindelin
2007-07-24 13:08                               ` Jon Smirl
2007-07-22 19:09 ` Linus Torvalds
2007-07-22 19:12   ` Jon Smirl
2007-07-22 19:37     ` Linus Torvalds
2007-07-22 19:17   ` David Kastrup
2007-07-22 19:47 ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707230136360.14781@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=jonsmirl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).