Applying Diff patches?
-
Does anyone know if NPP has the ability to apply diff patches to code? I didn’t see anything in the Plugins Admin, nor in the docs.
I’d be interested to know if anyone has attempted a homebrew solution using NppExec or Pythonscript as well.
-
@pbarney ,
If you have git, the
git applycan apply patches even when the target isn’t under git control (according to my web search results, anyway; I’ve never tried it myself). So putting the patch file in the right directory, and using the NppExec to just run something like the following should workcd "$(CURRENT_DIRECTORY)" git apply "$(FILE_NAME)"Alternately, I would say the most natural plugin for that feature to exist in would be the ComparePlus plugin. Unfortunately, the request for generating patchfiles has been un-implemented since 2019, so a new FR to also be able to apply a patch would likely not be implemented anytime soon.
update: who knows if it will do any good, but I commented on that Issue to request that apply patch be considered alongside create patch.
-
This post is deleted! -
Using PS3 and an installed pygit2 library
you can do something likeimport pygit2 repo = pygit2.Repository(Path(notepad.getCurrentFilename()).parent) diff = pygit2.Diff.parse_diff(editor.getText()) repo.apply(diff)This assumes that
- the patch file has been created from a git tool
- the current file open is the patch file in question
- the patch file is in the repo directory
-
@PeterJones said in Applying Diff patches?:
I commented on that Issue to request that apply patch be considered alongside create patch.
as mentioned here, as of ComparePlus v2.0.0, the plugin can generate and apply standard patch files; see also the release notes. Thanks to @pnedev for the update.
(Until it makes it into the Plugins Admin, the new version can be manually installed from the zipfiles found on the v2.0.0 release page)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login