>>>>> "LT" == Linus Torvalds <[EMAIL PROTECTED]> writes:
LT> And as you can see, the output matches "diff-tree -r" output (we always do LT> "-r", since the index is always fully populated). All the same rules: "+" LT> means added file, "-" means removed file, and "*" means changed file. You LT> can trivially see that the above is a rename. I do not know if Pasky tools already have something like this already, or not; but just FIY, here is what I use to extract a "patch" out of a working tree. Usage: $ diff-tree -z [-r] ... | jit-diff-tree-helper [ | less ] $ diff-cache -z ... | jit-diff-tree-helper [ | less ] This would be useful for the merge I described in my initial message in this thread to take a snapshot of what the user has done since the last commit, to be applied on the result of the merge. Signed-off-by: Junio C Hamano <[EMAIL PROTECTED]> --- --- jit-diff-tree-helper 2005-03-19 15:28:25.000000000 -0800 +++ jit-diff-tree-helper 2005-04-20 19:15:32.000000000 -0700 @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w + +use strict; +use File::Temp qw(mkstemp); + +sub cat_file { + my ($sha1, $file) = @_; + unless (defined $sha1) { return "/dev/null"; } + if ($sha1 =~ /^0{40}$/) { + open I, '<', $file; + } else { + local $/; # slurp mode + open I, "-|", "cat-file", "blob", $sha1 + or die "$0: cannot read $sha1"; + } + my ($o, $filename) = mkstemp(",,jit-diff-tree-helperXXXXXX"); + print $o join("",<I>); + close I + or die "$0: closing cat-file pipe from $sha1"; + close $o + or die "$0: closing write fd to $filename"; + return $filename; +} +$/ = "\0"; +my $rM = "[0-7]+"; +my $rI = "[0-9a-f]{40}"; +while (<STDIN>) { + my ($old, $new, $file); + chomp; + if (/^\+$rM\tblob\t($rI)\t(.*)$/os) { + ($old, $new, $file) = (undef, $1, $2); + } + elsif (/^-$rM\tblob\t($rI)\t(.*)$/os) { + ($old, $new, $file) = ($1, undef, $2); + } + elsif (/^\*$rM->$rM\tblob\t($rI)->($rI)\t(.*)$/os) { + ($old, $new, $file) = ($1, $2, $3); + } + else { + chomp; + print STDERR "warning: $0: ignoring $_\n"; + next; + } + if (@ARGV) { + my $matches = 0; + for (@ARGV) { + my $l = length($_); + if ($file eq $_ || + (substr($file, 0, $l) eq $_ && + substr($file, $l, 1) eq "/")) { + $matches = 1; + last; + } + } + next unless $matches; + } + $old = cat_file $old, $file; + $new = cat_file $new, $file; + system "diff", "-L", "l/$file", "-L", "k/$file", "-pu", $old, $new; + for ($old, $new) { + unlink $_ if $_ ne '/dev/null'; + } +} - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html