I have a big patch (foo), consisting of diffs from many files. I want to exclude a specific diff (corresponding to a single file) from this patch. The beginning of this diff looks like this:

diff --git a/business/smyt/scans/deboo.2015.02.11.pdf b/business/smyt/scans/deboo.2015.02.11.pdf
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4d5780b2dc843386b9641f4cb42a4ba4a7996cae
GIT binary patch
literal 106388

I'm trying the following command. Filterdiff is available on Debian, at least, in the patchutils package.

filterdiff --exclude='*/deboo.2015.02.11.pdf' foo > newfoo

but it returns the same file. This is probably user error. The man page (man filterdiff) says:

-x PATTERN, --exclude=PATTERN
       Exclude files matching PATTERN. All other lines in the input are displayed.

This probably requires usage of regular expressions, something which I have never been comfortable with.

Another method of doing this would also be fine. I could manually edit the patch as a last resort, but automated methods are generally better.

share|improve this question
    
I tried filterdiff --exclude='.*/deboo.2015.02.11.pdf' foo > newfoo. Still doesn't work. – Faheem Mitha Mar 7 '15 at 8:33

It might be that filterdiff doesn't know how to handle the git option as your PATTERN seems ok:

$ mkdir a b
$ seq 5 > a/file1
$ rm file1 
rm: remove regular file ‘file1’? y
$ seq 5 > b/file2
$ seq 4 > b/file1
$ seq 4 > a/file2
$ diff -r -u a b
diff -r -u a/file1 b/file1
--- a/file1 2015-03-07 09:24:15.548744157 +0100
+++ b/file1 2015-03-07 09:24:37.804744069 +0100
@@ -2,4 +2,3 @@
 2
 3
 4
-5
diff -r -u a/file2 b/file2
--- a/file2 2015-03-07 09:24:42.448744051 +0100
+++ b/file2 2015-03-07 09:24:30.684744097 +0100
@@ -2,3 +2,4 @@
 2
 3
 4
+5
$ diff -r -u a b > my.patch
$ wc my.patch
 16  46 302 my.patch
$ filterdiff --exclude='*/file2' my.patch | wc
      9      28     178
$ filterdiff --exclude='*/file2' my.patch 
diff -r -u a/file1 b/file1
--- a/file1 2015-03-07 09:24:15.548744157 +0100
+++ b/file1 2015-03-07 09:24:37.804744069 +0100
@@ -2,4 +2,3 @@
 2
 3
 4
-5
diff -r -u a/file2 b/file2
share|improve this answer
    
There is also the depth issue. There is a p flag for handling this, like with patch, but again I'm not sure how to use it. – Faheem Mitha Mar 7 '15 at 8:53
    
@FaheemMitha I don't think that patch depth is relevant here. Have you tried cut-and-pasting the full name? – Anthon Mar 7 '15 at 9:02
    
Sorry, not sure what you mean. – Faheem Mitha Mar 7 '15 at 9:09
    
filterdiff --exclude='a/business/smyt/scans/deboo.2015.02.11.pdf' foo instead of using the * – Anthon Mar 7 '15 at 9:11
    
filterdiff --exclude='a/business/smyt/scans/deboo.2015.02.11.pdf' foo doesn't work either. – Faheem Mitha Mar 8 '15 at 6:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.