Test functionality of new config variable "diff.primer" Signed-off-by: Keith Cascio <keith@xxxxxxxxxxx> --- t/t4035-diff-primer.sh | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 129 insertions(+), 0 deletions(-) create mode 100755 t/t4035-diff-primer.sh diff --git a/t/t4035-diff-primer.sh b/t/t4035-diff-primer.sh new file mode 100755 index 0000000..c33911c --- /dev/null +++ b/t/t4035-diff-primer.sh @@ -0,0 +1,129 @@ +#!/bin/sh +# +# Copyright (c) 2009 Keith G. Cascio +# +# based on t4015-diff-whitespace.sh by Johannes E. Schindelin +# + +test_description='Ensure diff engine honors config variable "diff.primer". + +' +. ./test-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh + +tr 'Q' '\015' << EOF > x +whitespace at beginning +whitespace change +whitespace in the middle +whitespace at end +unchanged line +CR at endQ +EOF + +git add x +git commit -m '1.0' >/dev/null 2>&1 + +tr '_' ' ' << EOF > x + whitespace at beginning +whitespace change +white space in the middle +whitespace at end__ +unchanged line +CR at end +EOF + +test_expect_success 'ensure diff.primer born empty' ' +[ -z $(git config --get diff.primer) ] +' + +tr 'Q_' '\015 ' << EOF > expect_noprimer +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning +-whitespace change +-whitespace in the middle +-whitespace at end ++ whitespace at beginning ++whitespace change ++white space in the middle ++whitespace at end__ + unchanged line +-CR at endQ ++CR at end +EOF +git diff > out +test_expect_success 'test git-diff with empty value of diff.primer' 'test_cmp expect_noprimer out' + +git config diff.primer '-w' + +test_expect_success 'ensure diff.primer value set' ' +[ $(git config --get diff.primer) = "-w" ] +' + +git diff --no-primer > out +test_expect_success 'test git-diff --no-primer' 'test_cmp expect_noprimer out' +git diff-files -p > out +test_expect_success 'ensure diff-files unaffected by diff.primer' 'test_cmp expect_noprimer out' +git diff-index -p HEAD > out +test_expect_success 'ensure diff-index unaffected by diff.primer' 'test_cmp expect_noprimer out' + +cat << EOF > expect_primer +diff --git a/x b/x +index d99af23..8b32fb5 100644 +EOF +git diff > out +test_expect_success 'test git-diff with diff.primer = -w' 'test_cmp expect_primer out' +git diff-files -p --primer > out +test_expect_success 'ensure diff-files honors --primer' 'test_cmp expect_primer out' +git diff-index -p --primer HEAD > out +test_expect_success 'ensure diff-index honors --primer' 'test_cmp expect_primer out' + +git add x +git commit -m 'whitespace changes' >/dev/null 2>&1 + +git config diff.primer '-w --color' + +tr 'Q_' '\015 ' << EOF > expect +Subject: [PATCH] whitespace changes + +--- + x | 10 +++++----- + 1 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning +-whitespace change +-whitespace in the middle +-whitespace at end ++ whitespace at beginning ++whitespace change ++white space in the middle ++whitespace at end__ + unchanged line +-CR at endQ ++CR at end +--_ +EOF + +git format-patch --stdout HEAD^..HEAD 2>&1 | sed -re '1,3d;$d' | sed -re '$d' > out +test_expect_success 'ensure format-patch unaffected by diff.primer' 'test_cmp expect out' + +git add x +git commit -m '2.0' >/dev/null 2>&1 + +git config diff.primer '-w' + +git diff-tree -p -r HEAD^ HEAD > out +test_expect_success 'ensure diff-tree unaffected by diff.primer' 'test_cmp expect_noprimer out' +git diff-tree -p -r --primer HEAD^ HEAD > out +test_expect_success 'ensure diff-tree honors --primer' 'test_cmp expect_primer out' + +test_done + -- 1.6.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html