blob: c4606bd4b7f0aa3f64335569cd5c379f6617f59e [file] [log] [blame]
Ævar Arnfjörð Bjarmason15b808d2021-10-15 11:30:16 +02001. "$TEST_DIRECTORY"/lib-diff-data.sh
2
Junio C Hamanoedb0c722005-05-31 14:47:25 -07003:
4
brian m. carlson2ece6ad2018-05-13 02:24:15 +00005sanitize_diff_raw='/^:/s/ '"\($OID_REGEX\)"' '"\($OID_REGEX\)"' \([A-Z]\)[0-9]* / \1 \2 \3# /'
Junio C Hamanoedb0c722005-05-31 14:47:25 -07006compare_diff_raw () {
7 # When heuristics are improved, the score numbers would change.
8 # Ignore them while comparing.
9 # Also we do not check SHA1 hash generation in this test, which
10 # is a job for t0000-basic.sh
11
12 sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
13 sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
Junio C Hamano3af82862008-05-23 22:28:56 -070014 test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
Junio C Hamanoedb0c722005-05-31 14:47:25 -070015}
16
brian m. carlson2ece6ad2018-05-13 02:24:15 +000017sanitize_diff_raw_z='/^:/s/ '"$OID_REGEX"' '"$OID_REGEX"' \([A-Z]\)[0-9]*$/ X X \1#/'
Junio C Hamanoedb0c722005-05-31 14:47:25 -070018compare_diff_raw_z () {
19 # When heuristics are improved, the score numbers would change.
20 # Ignore them while comparing.
21 # Also we do not check SHA1 hash generation in this test, which
22 # is a job for t0000-basic.sh
23
Jeff Kinge85fe4d2008-03-12 17:31:06 -040024 perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
25 perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
Junio C Hamano3af82862008-05-23 22:28:56 -070026 test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
Junio C Hamanoedb0c722005-05-31 14:47:25 -070027}
28
29compare_diff_patch () {
30 # When heuristics are improved, the score numbers would change.
31 # Ignore them while comparing.
Junio C Hamanoec1fcc12005-10-07 03:42:00 -070032 sed -e '
33 /^[dis]*imilarity index [0-9]*%$/d
34 /^index [0-9a-f]*\.\.[0-9a-f]/d
35 ' <"$1" >.tmp-1
36 sed -e '
37 /^[dis]*imilarity index [0-9]*%$/d
38 /^index [0-9a-f]*\.\.[0-9a-f]/d
39 ' <"$2" >.tmp-2
Junio C Hamano3af82862008-05-23 22:28:56 -070040 test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
Junio C Hamanoedb0c722005-05-31 14:47:25 -070041}