10

Sometimes I need to split a big patch into smaller (disjoint) ones, e.g. for every separate feature included.

Usually I do it via standard vim yank/dd commands and split-window switching.

But are there some tools/vim-tricks to help with such kind of editing?

For example support for commands like: move the 3 next complete hunks to right opened patch file

2
7

You might want to take a look into patchutils [1]. For the vim part, I wrote a small vim plugin that helps with navigating in patches: diff_navigator [2].

[1] http://cyberelk.net/tim/software/patchutils/

[2] http://www.vim.org/scripts/script.php?script_id=2361

2
  • 1
    The diff_navigator URL is apparently vim.org/scripts/script.php?script_id=2361 Emacs has similar features in the Ediff and SMerge modes – Riccardo Murri Oct 1 '10 at 9:59
  • 2
    Could you extend your answer to make it more comprehensive? Adding an example how to use what utility from the patchutils set to split a big patch into disjoint ones would be great ... – maxschlepzig Aug 30 '11 at 20:05
5

Somewhat off-topic, I guess but I still think it's useful.

If you use git to do your development you can easily split your whole changes into smaller "hunks" that embody one feature each. You end up with one commit per feature and can use git's git-format-patch to create (and even sign and properly attribute) patches, I outlined how to do that here

3

My Suse has splitdiff util which works like this:

$ splitdiff -a tmp.179639.patch
Wrote >tmp.179639.patch.part001
Wrote >tmp.179639.patch.part002
0

You can use this to split the big patch to smaller chunks (either per file or every hunk) and then if you need to merge then use combinediff from the patchutils package that was mentioned in Petr Uzel's answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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