mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
15b808da74
Follow-up the change in459b8d22e5
(tests: do not borrow from COPYING and README from the real source, 2015-02-15) by not shipping a full copy of older versions of the top-level "COPYING" and "README" files. The tests that use them just need the small blurb at the top of "COPYING" as test data, or mock data that's dissimilar. Let's provide that with a "COPYING_test_data" function instead. We're not replacing this with some other generic test data (e.g. "lorum ipsum") because these tests require test file header to be the old "COPYING" file. See e.g. "t4003-diff-rename-1.sh" which changes the file, and then does full "test_cmp" comparisons on the resulting "git diff" output. This change only changes tests that used the "lib-diff.sh" library, but splits up what they need into a new "lib-diff-data.sh". A subsequent commit will change related tests that were missed in459b8d22e5
. For the test in "t4008-diff-break-rewrite.sh" the "README" file can go away in favor of echoing the line "some dissimilar content" to a file in the one test that needed it. The point of that test is to start with files "A" and "B", and then have A be more similar to the state of "B" than to its old version (by copying over the content from the "COPYING" file). Just comparing the pre-image of "some dissimilar content" and later a munged version of the "COPYING" output serves that purpose. While we're at it get rid of a stray "echo $tree" debugging line added in15d061b435
([PATCH] Fix the way diffcore-rename records unremoved source., 2005-05-27), and stop calling "hash-object" to get the hash of an object we've just added to the index. We can instead extract that information from the index itself with "rev-parse". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
41 lines
1.4 KiB
Bash
41 lines
1.4 KiB
Bash
. "$TEST_DIRECTORY"/lib-diff-data.sh
|
|
|
|
:
|
|
|
|
sanitize_diff_raw='/^:/s/ '"\($OID_REGEX\)"' '"\($OID_REGEX\)"' \([A-Z]\)[0-9]* / \1 \2 \3# /'
|
|
compare_diff_raw () {
|
|
# When heuristics are improved, the score numbers would change.
|
|
# Ignore them while comparing.
|
|
# Also we do not check SHA1 hash generation in this test, which
|
|
# is a job for t0000-basic.sh
|
|
|
|
sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
|
|
sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
|
|
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
|
|
}
|
|
|
|
sanitize_diff_raw_z='/^:/s/ '"$OID_REGEX"' '"$OID_REGEX"' \([A-Z]\)[0-9]*$/ X X \1#/'
|
|
compare_diff_raw_z () {
|
|
# When heuristics are improved, the score numbers would change.
|
|
# Ignore them while comparing.
|
|
# Also we do not check SHA1 hash generation in this test, which
|
|
# is a job for t0000-basic.sh
|
|
|
|
perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
|
|
perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
|
|
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
|
|
}
|
|
|
|
compare_diff_patch () {
|
|
# When heuristics are improved, the score numbers would change.
|
|
# Ignore them while comparing.
|
|
sed -e '
|
|
/^[dis]*imilarity index [0-9]*%$/d
|
|
/^index [0-9a-f]*\.\.[0-9a-f]/d
|
|
' <"$1" >.tmp-1
|
|
sed -e '
|
|
/^[dis]*imilarity index [0-9]*%$/d
|
|
/^index [0-9a-f]*\.\.[0-9a-f]/d
|
|
' <"$2" >.tmp-2
|
|
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
|
|
}
|