Use case: So you have a patch that you want to backport and it's fitting well modulo offsets. You want convenient, non-tedious way to get perfectly fitting one. How to achieve it: $ patch-fix-offsets -p1 wrongoffsets.patch > goodoffsets.patch $ # alternatively with recountdiff pass appended via pipe for extra sanity Alternatives: 1. apply patch and rediff (possibly changing the format of the patch!) $ cp -pR ${PROJECT_DIR}{,.orig} $ patch -p1 goodoffsets.patch $ mv ${PROJECT_DIR}{.orig,} TBD: wiggle, merge, ... Tools included: fix-offsets: can either change offsets using limited expressions (DSL, see fix-offsets -h) to specify the desired offset changes, or using its own (and currently limited and buggy) method directly against the target codebase (for latter use case please refer to patch-fix-offsets below); as a bonus, the through-away prefixes in paths within a patch are (optionally, by default) normalized as per git diff conventions patch-fix-offsets: will try to apply, in a dry-run manner, the patch and based on the patch utility feedback (hunk succeeded with offset X) will produce an offset expression subsequently feeded into fix-offsets tool (sort of a wrapper to bypass custom logic in fix-offsets) Notable related tools (with a bit different intentions, though): wiggle: http://neil.brown.name/wiggle/ patchutils: https://fedorahosted.org/patchutils/wiki (used by gdp: https://gitorious.org/gdp) Quilt: http://savannah.nongnu.org/projects/quilt Please let me know if there are others handy (surely are!) or if there is something better to solve the use case with as least effort (either manual or computational like having the whole alternative tree externalized on the filesystem) as possible. -- Jan jpokorn yr edha tc om