public inbox for patchutils-list@sourceware.org
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: patchutils-list@sourceware.org
Cc: Wolfram Sang <w.sang@pengutronix.de>
Subject: [patch 1/1] splitdiff: add option to extract the whole tree of subdiffs
Date: Mon, 02 Feb 2009 22:14:00 -0000	[thread overview]
Message-ID: <20090202221522.584037252@pengutronix.de> (raw)
In-Reply-To: <20090202221217.790916412@pengutronix.de>

[-- Attachment #1: splitdiff_create_tree --]
[-- Type: text/plain, Size: 2027 bytes --]

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 <w.sang@pengutronix.de>
---
 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 = <LIST>;
 close LIST;

  reply	other threads:[~2009-02-02 22:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-02 22:14 [patch 0/1] New feature for splitdiff Wolfram Sang
2009-02-02 22:14 ` Wolfram Sang [this message]
2009-02-03 11:12   ` [patch v2] splitdiff: add option to extract the whole tree of subdiffs Wolfram Sang

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=20090202221522.584037252@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=patchutils-list@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).