Skip to content
This repository was archived by the owner on Dec 6, 2020. It is now read-only.

Commit 4fb48bc

Browse files
committed
Fix translation of unified diff to normal diff
Fixes issue #5.
1 parent 4a2eeb8 commit 4fb48bc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Diff for: diff-ignore-moved-lines.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# https://github.com/l0b0/diff-ignore-moved-lines/issues
2121
#
2222
# COPYRIGHT
23-
# Copyright (C) 2011-2012 Victor Engmark
23+
# Copyright (C) 2011-2014 Victor Engmark
2424
#
2525
# This program is free software: you can redistribute it and/or modify
2626
# it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ set -o errexit -o noclobber -o nounset -o pipefail
4141

4242
# Only output diff lines (context lines and such would not be accurate anyway)
4343
# Also, convert unified diffs to "normal" diffs
44-
diff_lines="$(grep '^[><+-] ' | sed 's/^+/>/;s/^-/</')" || exit 0
44+
diff_lines="$(grep -v '^\(---\|+++\|@@ \)'| grep '^\([><] \)\|[+-]' | sed 's/^+/> /;s/^-/< /')" || exit 0
4545

4646
while IFS= read -r line || [ -n "$line" ]
4747
do

Diff for: test.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ Yoda
9191
"Moved and changed lines" \
9292
"$diff"x \
9393
"$(diff <(printf %s "$file1") <(printf %s "$file2") | "$cmd" || printf x)"
94+
95+
assertEquals \
96+
"Moved and changed lines (unified)" \
97+
"$diff"x \
98+
"$(diff -u <(printf %s "$file1") <(printf %s "$file2") | "$cmd" || printf x)"
9499
}
95100

96101
# load and run shUnit2
97102
test -n "${ZSH_VERSION:-}" && SHUNIT_PARENT=$0
98-
. /usr/share/shunit2/shunit2
103+
. shunit2

0 commit comments

Comments
 (0)