sdgfsdh
sdgfsdh

Reputation: 37065

Remove changes to a particular file from a patch-file

I have a patch file that changes many files. It accidentally includes changes to some files that it shouldn't. I can manually remove all mention of these files from the patch to yield a correct patch file, but this is a tedious process.

How can I programmatically (standard *nix tools) remove all mentions of a file from a patch?


Note: I do not have the Git setup that the patch was originally generated from, so I am only interested in solutions that work just on the patch file. Given the structure of these files this should be feasible.

This question concerns Git: Create a Patch file excluding some files

This question concerns TFS: How to remove particular file of a changeset?

Upvotes: 2

Views: 1745

Answers (1)

jhnc
jhnc

Reputation: 16761

Many linux distributions provide patchutils which includes several utilities for this:

Filterdiff will select the portions of a patch file that apply to files matching (or, alternatively, not matching) a shell wildcard.

Splitdiff separates out patches from a patch file so that each new patch file only alters any given file once. In this way, a file containing several incremental patches can be split into individual incremental patches.

Upvotes: 5

Related Questions