From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2962 invoked by alias); 2 Feb 2009 22:14:40 -0000 Received: (qmail 2953 invoked by uid 22791); 2 Feb 2009 22:14:39 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_44 X-Spam-Check-By: sourceware.org Received: from metis.ext.pengutronix.de (HELO metis.ext.pengutronix.de) (92.198.50.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Feb 2009 22:14:35 +0000 Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=localhost) by metis.ext.pengutronix.de with esmtp (Exim 4.63) (envelope-from ) id 1LU73m-0001Ib-2k; Mon, 02 Feb 2009 23:14:33 +0100 Message-Id: <20090202221522.584037252@pengutronix.de> User-Agent: quilt/0.47-1 Date: Mon, 02 Feb 2009 22:14:00 -0000 From: Wolfram Sang To: patchutils-list@sourceware.org Cc: Wolfram Sang References: <20090202221217.790916412@pengutronix.de> Content-Disposition: inline; filename=splitdiff_create_tree X-SA-Exim-Connect-IP: 92.198.50.58 X-SA-Exim-Mail-From: w.sang@pengutronix.de Subject: [patch 1/1] splitdiff: add option to extract the whole tree of subdiffs X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: patchutils-list@sourceware.org Mailing-List: contact patchutils-list-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: patchutils-list-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00001.txt.bz2 Sometimes I get a huge patch blob (a couple of MB) which touches several files all over a base directory (in this case the linux kernel tree). This new option to splitdiff creates the path for every subdiff inside the blob and extracts it to there. So, in the end, you get a directory tree you are familiar with and can easily find the small diffs which are of interest to you. Also, useful for grepping in certain parts of the tree. Signed-off-by: Wolfram Sang --- splitdiff.in | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) Index: splitdiff.in =================================================================== --- splitdiff.in.orig +++ splitdiff.in @@ -18,7 +18,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use Getopt::Std; -getopts('p:v-:ad', \%opts); +use File::Basename; +use File::Path; + +getopts('p:v-:adt', \%opts); if ($opts{'-'} && $opts{'-'} eq 'version') { print "splitdiff - patchutils version @VERSION@\n"; exit 0; @@ -29,6 +32,7 @@ if ($opts{'-'} && $opts{'-'} eq 'help') print " -a split out every single file-level patch\n"; print " -p N pathname components to ignore\n"; print " -d use output filenames like a_b.c for a/b.c\n"; + print " -t create the whole tree of subdiffs (selects -a, drops -d)"; exit 0; } @@ -44,6 +48,10 @@ sub process { if ($opts{d}) { $out = $_[2]; $out =~ s,/,_,g; + } elsif ($opts{t}) { + my (undef, $dir) = fileparse($_[2]); + mkpath $dir; + $out = "$_[2].diff"; } else { $out = sprintf ("%s.part%03d", $ARGV[0], $part); } @@ -66,6 +74,12 @@ if($#ARGV != 0) { $getlist = 'lsdiff -n '; $getlist .= '--strip='.$opts{p}.' ' if ($opts{p}); $getlist .= $ARGV[0]; # Yuck. How do you do this properly in perl? + +if ($opts{t}) { + $opts{a} = 1; + undef $opts{d}; +} + open(LIST, '-|', $getlist) or die "Can't run lsdiff"; @list = ; close LIST;