https://github.com/andrewradev/diffurcate.vim
Split a git diff into separate files
https://github.com/andrewradev/diffurcate.vim
Last synced: 5 months ago
JSON representation
Split a git diff into separate files
- Host: GitHub
- URL: https://github.com/andrewradev/diffurcate.vim
- Owner: AndrewRadev
- License: mit
- Created: 2021-10-17T09:22:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-28T14:01:21.000Z (over 2 years ago)
- Last Synced: 2023-04-10T08:20:56.364Z (about 2 years ago)
- Language: Ruby
- Size: 16.6 KB
- Stars: 55
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://circleci.com/gh/AndrewRadev/diffurcate.vim?branch=main)
## Usage
The plugin comes with only one command, `:Diffurcate`. Open a git diff and execute the command, and it'll open a new tab in a temporary directory that contains separate diffs per file, mirroring the original directory structure. If you happen to have the NERDTree plugin installed, it'll open it as well (happy to add similar functionality for other navigation plugins, just open a github issue).

You can do this with a file on the filesystem, or just redirect the output from a git command, for example:
``` bash
git diff | vim - -R +Diffurcate
```At the moment, this only works on git diffs, but if you'd like to get support for other VCS diffs, it shouldn't be too hard to implement.
## Internals
The plugin uses Vim's `tempname()` function to create a temporary directory that will be deleted when Vim exits. That's where it creates each individual file. It uses regexes to figure out where the individual diffs start and end, so if it messes something up, it might be the pattern doesn't cover all the right cases -- please open a github issue and we'll figure it out.
## Naming
Picked the name from Doug's suggestion here:
Very grateful for all the ideas from the replies to both of these tweets:
-
-## Contributing
Pull requests are welcome, but take a look at [CONTRIBUTING.md](https://github.com/AndrewRadev/diffurcate.vim/blob/main/CONTRIBUTING.md) first for some guidelines. Be sure to abide by the [CODE_OF_CONDUCT.md](https://github.com/AndrewRadev/diffurcate.vim/blob/master/CODE_OF_CONDUCT.md) as well.