Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 489383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:48:09+00:00 2026-05-13T01:48:09+00:00

Every time I want to take a subset of a patch, I’m forced to

  • 0

Every time I want to take a subset of a patch, I’m forced to write a script to only extract the indices that I want.

e.g. I have a patch that applies to sub directories
‘yay’ and ‘foo’.

Is there a way to create a new patch or apply only a subset of a patch? i.e. create a new patch from the existing patch that only takes all indices that are under sub directory ‘yay’. Or all indices that are not under sub directory ‘foo’

If I have a patch like ( excuse the below pseudo-patch):

Index : foo/bar
 yada
 yada
- asdf
+ jkl
 yada
 yada
Index : foo/bah
 blah
 blah
- 28
+ 29
 blah
 blah
 blah
Index : yay/team
 go
 huskies
- happy happy
+ joy joy
 cougars
 suck

How can I extract or apply only the ‘yay’ subdirectory like:

Index : yay/team
 go
 huskies
- happy happy
+ joy joy
 cougars
 suck

I know if I script up a solution I’ll be re-inventing the wheel…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:48:09+00:00Added an answer on May 13, 2026 at 1:48 am

    Take a look at the filterdiff utility, which is part of patchutils.

    For example, if you have the following patch:

    $ cat example.patch
    diff -Naur orig/a/bar new/a/bar
    --- orig/a/bar  2009-12-02 12:41:38.353745751 -0800
    +++ new/a/bar   2009-12-02 12:42:17.845745951 -0800
    @@ -1,3 +1,3 @@
     4
    -5
    +e
     6
    diff -Naur orig/a/foo new/a/foo
    --- orig/a/foo  2009-12-02 12:41:32.845745768 -0800
    +++ new/a/foo   2009-12-02 12:42:25.697995617 -0800
    @@ -1,3 +1,3 @@
     1
     2
    -3
    +c
    diff -Naur orig/b/baz new/b/baz
    --- orig/b/baz  2009-12-02 12:41:42.993745756 -0800
    +++ new/b/baz   2009-12-02 12:42:37.585745735 -0800
    @@ -1,3 +1,3 @@
    -7
    +z
     8
     9
    

    Then you can run the following command to extract the patch for only things in the a directory like this:

    $ cat example.patch | filterdiff -i 'new/a/*'
    --- orig/a/bar  2009-12-02 12:41:38.353745751 -0800
    +++ new/a/bar   2009-12-02 12:42:17.845745951 -0800
    @@ -1,3 +1,3 @@
     4
    -5
    +e
     6
    --- orig/a/foo  2009-12-02 12:41:32.845745768 -0800
    +++ new/a/foo   2009-12-02 12:42:25.697995617 -0800
    @@ -1,3 +1,3 @@
     1
     2
    -3
    +c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that every time I want to perform a db query, I have
I have a single value in a table that I want selected every time
How can I make a loop that can take user input every time it
I want to change taxt value from loop and every time I have changed
I Have a hosted service on Azure, every time I want to put the
I have a database that time stamps every five minutes, or less if the
i have a table with about 100 rows , and i want every time
In symfony 2 controllers, every time I want to get a value from post
Seriously, it seems like every time I want to make my UI elements talk
In my activity there is a toggle button. I want every time you change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.