From 877f23ccb88227203f2576abdfb5d1c15925fcb3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Jun 2008 15:36:59 -0700 Subject: Teach "diff --check" about new blank lines at end When a patch adds new blank lines at the end, "git apply --whitespace" warns. This teaches "diff --check" to do the same. Signed-off-by: Junio C Hamano --- t/t4015-diff-whitespace.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index b7cc6b28e6..0922c708f1 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -335,4 +335,10 @@ test_expect_success 'line numbers in --check output are correct' ' ' +test_expect_success 'checkdiff detects trailing blank lines' ' + echo "foo();" >x && + echo "" >>x && + git diff --check | grep "ends with blank" +' + test_done -- cgit v1.2.3 From 049540435fa5f7f583b8f5af257322b17eac7375 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Jun 2008 15:37:21 -0700 Subject: diff --check: detect leftover conflict markers This teaches "diff --check" to detect and complain if the change adds lines that look like leftover conflict markers. We should be able to remove the old Perl script used in the sample pre-commit hook and modernize the script with this facility. Signed-off-by: Junio C Hamano --- t/t4017-diff-retval.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh index 0d0fb87f57..d748d45dae 100755 --- a/t/t4017-diff-retval.sh +++ b/t/t4017-diff-retval.sh @@ -113,4 +113,18 @@ test_expect_success 'check should test not just the last line' ' ' +test_expect_success 'check detects leftover conflict markers' ' + git reset --hard && + git checkout HEAD^ && + echo binary >>b && + git commit -m "side" b && + test_must_fail git merge master && + git add b && ( + git --no-pager diff --cached --check >test.out + test $? = 2 + ) && + test "$(grep "conflict marker" test.out | wc -l)" = 3 && + git reset --hard +' + test_done -- cgit v1.2.3 From ab20fda99236e38edf5d63f964b6b920b494aacb Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Sun, 29 Jun 2008 16:49:06 -0400 Subject: Fix t4017-diff-retval for white-space from wc Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- t/t4017-diff-retval.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh index d748d45dae..60dd2014d5 100755 --- a/t/t4017-diff-retval.sh +++ b/t/t4017-diff-retval.sh @@ -123,7 +123,7 @@ test_expect_success 'check detects leftover conflict markers' ' git --no-pager diff --cached --check >test.out test $? = 2 ) && - test "$(grep "conflict marker" test.out | wc -l)" = 3 && + test 3 = $(grep "conflict marker" test.out | wc -l) && git reset --hard ' -- cgit v1.2.3