Giter Club home page Giter Club logo

repatch's Introduction

re:patch

Latest Version

re:patch is a line-oriented find-and-replace tool with a git add --patch-like interface. Regular expressions and capture groups are supported, and re:patch can be used with files and directories. Only Linux is currently supported.

Warning

This tool is still in development. While it Works For Meβ„’, it does not yet have any tests. It's recommended to only use this in directories that are version controlled.

Install

You can install from source or through crates.io. You must have a recent rust/cargo toolchain installed.

# install the latest release from crates.io
cargo install repatch

# install from source
git clone https://github.com/stevenengler/repatch.git
cd repatch && cargo install --path .

Example

Command-line usage example.

Notes

Similar to ripgrep, gitignore rules are respected and hidden files/directories are ignored.

The editor used to edit patches can be configured using environment variables or the git configuration. The search priority is VISUAL, EDITOR, GIT_EDITOR, and git config core.editor. Otherwise vim is used. Like sudo -e the editor value is split by whitespace characters and executed, and is not interpreted by a shell.

Patches shown in the terminal will have ANSI escape sequences replaced with safe versions.

Like most text editors, files are replaced and not edited in-place. This means that the file owner or other metadata may change after editing. The new file will have the same read/write/execute permissions as the original file. You will also need enough temporary disk space for this second file. For example if you're editing a 10 GB file, you must have at least 10 GB of disk space free so that the new file can be written before the original file is deleted.

Large files (larger than the amount of available memory) are supported as long as they have a sufficient number of lines. For example a 10 GB file with 10,000 lines should work fine, but a 10 GB file with a single line might exhaust the system memory and would not look very nice in the terminal.

Acknowledgements

Most of the heavy lifting is done by the ripgrep family of crates, clap, and diffy.

repatch's People

Contributors

dependabot[bot] avatar stevenengler avatar

Watchers

 avatar  avatar

repatch's Issues

`O_TMPFILE` doesn't work on overlayfs (ex: docker)

O_TMPFILE only works on a select number of file systems, and overlayfs which is used by Docker does not support O_TMPFILE. A workaround is needed to support temporary files on unsupported file systems.

This surfaces as an error like:

ERROR: could not replace file './LICENSE': Operation not supported (os error 95)

This also causes the util::tests::test_replace_file test to fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.