linux - Diff-aware editor, that can handle patch hunk edits (incl. deletion of lines)? -
my question similar interactive program selectively exclude parts of diff file - different...
say have following "original" file:
$ cat test-orig.h int vara; int varb; int varc; int vard; int vare; ... , i've made these changes "new" file:
$ cat test-newmodified.h int vara; int varb; int varc; // couple of lines // of useless comments int var_extra1; int var_extra2; int vard; int vare; then diff between 2 be:
$ diff -naur test-orig.h test-newmodified.h | tee test.patch --- test-orig.h 2013-07-18 19:21:25.741027138 +0200 +++ test-newmodified.h 2013-07-18 19:21:19.916998200 +0200 @@ -1,5 +1,9 @@ int vara; int varb; int varc; +// couple of lines +// of useless comments +int var_extra1; +int var_extra2; int vard; int vare; let's then, have patch file obtained, (with many hunks), , i'd want delete "lines of useless comments". it's easy delete whole hunk diff generated patch file - if want delete lines, diff counters (above in @@ -1,5 +1,9 @@) have modified too. say, if comments line erased in file, diff be:
$ diff -naur test-orig.h test-newmodified-nc.h --- test-orig.h 2013-07-18 19:21:25.741027138 +0200 +++ test-newmodified-nc.h 2013-07-18 19:26:30.898540270 +0200 @@ -1,5 +1,7 @@ int vara; int varb; int varc; +int var_extra1; +int var_extra2; int vard; int vare; ... is, counters comments, @@ -1,5 +1,9 @@ - became, without comments, @@ -1,5 +1,7 @@.
if delete comment lines patch test.patch (and save edit test-edit.patch), , not update counters, get:
$ patch -p0 <test-edit.patch patching file test-orig.h patch: **** malformed patch @ line 10: ... , such patch doesn't applied. if, then, change +1,9 +1.7 in test-edit.patch, applies cleanly:
$ patch -p0 <test-edit.patch patching file test-orig.h ... , test-orig.h changed expected (without comment lines).
so, given patch file, hunks related file contained - there (gui) (text) editor diff aware (at least, unified diff), such that: when lines hunk (or entire hunks) deleted, automatically update diff counters - edited patch file still apply cleanly original file?
well, know can @ least use emacs this, answer: #9740489 how edit diff/patch file cleanly ? there patch file editors?:
if open diff file in emacs , put editor in "diff" mode can edit patches , update hunk markers in smart way
note on system (ubuntu lucid), sudo apt-get install emacs will, after installation, make emacs command symlink emacs23-x, runs in own window (not in terminal). can call:
$ emacs test.patch ... , emacs automatically start in "diff" mode:

then can select lines using mouse, cannot delete them using del/backspace - have cut selection using ctrl-w (see in emacs, how cut, paste, , copy block of text? - knowledge base). can seen screenshot, markers automatically updated. also, not go in "diff" mode using m-x diff (see comparing files - gnu emacs manual; on machine, m-x alt-x) - start asking "original" , "new" input file paths perform diff on them, not want (given patch file loaded). finally, gui menu has file/save (and c-x c-w shortcut it) - clicking on gui menu raises usual file dialog, edited file can renamed on save.
still, know if there alternatives this...
Comments
Post a Comment