Ignore leading and trailing blank lines for comparison

```git-check-assertions
run test/mechanicaldiff.bats
assert_success

git checkout HEAD~ bin
run test/mechanicaldiff.bats
assert_failure
assert_output --partial "-- command failed --"
```
This commit is contained in:
Sven van Heugten 2026-03-06 04:08:21 +01:00
parent 3d814b5b15
commit 0b3d0d8f46
No known key found for this signature in database
GPG key ID: D612F88666F4F660
2 changed files with 29 additions and 1 deletions

View file

@ -143,6 +143,24 @@ setup() {
assert_output "$(cat "$BATS_TEST_TMPDIR/diff")"
}
@test "ignores leading and trailing blank lines for comparison" {
cat >"$BATS_TEST_TMPDIR/old" <<-'EOF'
prefix foo suffix
EOF
cat >"$BATS_TEST_TMPDIR/new" <<-'EOF'
prefix bar suffix
EOF
git diff --no-index "$BATS_TEST_TMPDIR/old" "$BATS_TEST_TMPDIR/new" \
>"$BATS_TEST_TMPDIR/diff" || true
run mechanicaldiff.py foo bar <"$BATS_TEST_TMPDIR/diff"
assert_success
assert_output "$(cat "$BATS_TEST_TMPDIR/diff")"
}
@test "keeps only matching line in a consecutive change block" {
cat >"$BATS_TEST_TMPDIR/old" <<-'EOF'
foo