No description
Find a file
Sven van Heugten 057686a6b9
Fix changes sometimes disappearing entirely
```git-check-assertions
run test/mechanicaldiff.bats
assert_success

git checkout HEAD~ bin
run test/mechanicaldiff.bats
assert_failure
assert_output --partial "not ok 9 keeps matching change with an extra removed line"
assert_output --partial "not ok 10 keeps matching change with an extra added line"
```
2026-03-06 17:30:41 +01:00
bin Fix changes sometimes disappearing entirely 2026-03-06 17:30:41 +01:00
test Fix changes sometimes disappearing entirely 2026-03-06 17:30:41 +01:00
.editorconfig Add devshell and initial bats tests 2026-03-05 19:36:24 +01:00
.gitignore Add boilerplate 2026-03-05 17:26:52 +01:00
default.nix Fix changes sometimes disappearing entirely 2026-03-06 17:30:41 +01:00
flake.lock Add boilerplate 2026-03-05 17:26:52 +01:00
flake.nix Fix changes sometimes disappearing entirely 2026-03-06 17:30:41 +01:00
LICENSE Add LICENSE 2026-03-05 21:11:29 +01:00
README.md Add README 2026-03-06 04:29:23 +01:00

mechanicaldiff

mechanicaldiff lets you filter down a diff to only the parts that make a specific mechanical change, so you can commit those changes separately.

Usage: git diff | mechanicaldiff <pattern> <replacement>

It differs from grepdiff in that it doesnt just search for the lines that contain the given pattern, but also checks that the only change in that line is that pattern was replaced with the given replacement.

It differs from simply replacing pattern with replacement in the entire repository in that it filters down an existing diff, which means that the resulting diff doesnt make the mechanical change everywhere, but only in the lines that your original diff also made it.