IMO unless a scripted diff is badly written or fragile (e.g. hardcoding line numbers), I’d always prefer it over a manual change because it:
I understand why scripted-diffs are useful. However, you forgot to mention the risks and downsides:
- A script in the scripted-diff must be reviewed.
- Otherwise, it can accidentally or intentionally modify files that are not tracked by git (Which has happened in the past).
- Failing statements in the scripted-diff won’t cause the CI to fail, which is another way in which reviewers could be accidentally or intentionally tricked to think a script has executed when it did not, and they may miss a bug.
- Seeing a scripted-diff could encourage reviewers to skip or skim over the actual diff, missing bugs.
Also, the diff contained a statement, which looks like it shouldn’t be part of it, because it applies to one line of code. (sed -i 's/WalletLogPrintf("Releasing wallet\\n"/WalletLogPrintf("Releasing wallet %s..\\n", name/g' $(git grep -l '"Releasing wallet\\n"' ./src/wallet/wallet.cpp)
). I don’t see any benefit in putting that into a scripted-diff, which is why I mentioned it (and also left my comment on this line).
Obviously the rest of the script was fine, but personally just calling a single time git grep $old_value
is faster than to type ./test/lint/commit-script-check.sh HEAD~$N..HEAD
(or rely on the CI).