From 5bd74506cd30e897d1493639b7438c6cc80dea8e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 25 Feb 2007 23:36:53 +0100 Subject: Get rid of the dependency to GNU diff in the tests Now that "git diff" handles stdin and relative paths outside the working tree correctly, we can convert all instances of "diff -u" to "git diff". This commit is really the result of $ perl -pi.bak -e 's/diff -u/git diff/' $(git grep -l "diff -u" t/) Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano (cherry picked from commit c699a40d68215c7e44a5b26117a35c8a56fbd387) --- t/t4100-apply-stat.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 6579f06b05..7b81c32e57 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -11,37 +11,37 @@ test_description='git-apply --stat --summary test. test_expect_success \ 'rename' \ 'git-apply --stat --summary <../t4100/t-apply-1.patch >current && - diff -u ../t4100/t-apply-1.expect current' + git diff ../t4100/t-apply-1.expect current' test_expect_success \ 'copy' \ 'git-apply --stat --summary <../t4100/t-apply-2.patch >current && - diff -u ../t4100/t-apply-2.expect current' + git diff ../t4100/t-apply-2.expect current' test_expect_success \ 'rewrite' \ 'git-apply --stat --summary <../t4100/t-apply-3.patch >current && - diff -u ../t4100/t-apply-3.expect current' + git diff ../t4100/t-apply-3.expect current' test_expect_success \ 'mode' \ 'git-apply --stat --summary <../t4100/t-apply-4.patch >current && - diff -u ../t4100/t-apply-4.expect current' + git diff ../t4100/t-apply-4.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-5.patch >current && - diff -u ../t4100/t-apply-5.expect current' + git diff ../t4100/t-apply-5.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-6.patch >current && - diff -u ../t4100/t-apply-6.expect current' + git diff ../t4100/t-apply-6.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-7.patch >current && - diff -u ../t4100/t-apply-7.expect current' + git diff ../t4100/t-apply-7.expect current' test_done -- cgit v1.2.3 From a6080a0a44d5ead84db3dabbbc80e82df838533d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 7 Jun 2007 00:04:01 -0700 Subject: War on whitespace This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 1 - 1 file changed, 1 deletion(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 7b81c32e57..c23341feb5 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -44,4 +44,3 @@ test_expect_success \ git diff ../t4100/t-apply-7.expect current' test_done - -- cgit v1.2.3 From 5be60078c935ed08ee8eb5a32680bdfb6bb5bdf3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 2 Jul 2007 22:52:14 -0700 Subject: Rewrite "git-frotz" to "git frotz" This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index c23341feb5..435f65b370 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -3,44 +3,44 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply --stat --summary test. +test_description='git apply --stat --summary test. ' . ./test-lib.sh test_expect_success \ 'rename' \ - 'git-apply --stat --summary <../t4100/t-apply-1.patch >current && + 'git apply --stat --summary <../t4100/t-apply-1.patch >current && git diff ../t4100/t-apply-1.expect current' test_expect_success \ 'copy' \ - 'git-apply --stat --summary <../t4100/t-apply-2.patch >current && + 'git apply --stat --summary <../t4100/t-apply-2.patch >current && git diff ../t4100/t-apply-2.expect current' test_expect_success \ 'rewrite' \ - 'git-apply --stat --summary <../t4100/t-apply-3.patch >current && + 'git apply --stat --summary <../t4100/t-apply-3.patch >current && git diff ../t4100/t-apply-3.expect current' test_expect_success \ 'mode' \ - 'git-apply --stat --summary <../t4100/t-apply-4.patch >current && + 'git apply --stat --summary <../t4100/t-apply-4.patch >current && git diff ../t4100/t-apply-4.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-5.patch >current && + 'git apply --stat --summary <../t4100/t-apply-5.patch >current && git diff ../t4100/t-apply-5.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-6.patch >current && + 'git apply --stat --summary <../t4100/t-apply-6.patch >current && git diff ../t4100/t-apply-6.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-7.patch >current && + 'git apply --stat --summary <../t4100/t-apply-7.patch >current && git diff ../t4100/t-apply-7.expect current' test_done -- cgit v1.2.3 From 3af828634fa5bdbca1b2061a81df8b3fa73b0d34 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 May 2008 22:28:56 -0700 Subject: tests: do not use implicit "git diff --no-index" As a general principle, we should not use "git diff" to validate the results of what git command that is being tested has done. We would not know if we are testing the command in question, or locating a bug in the cute hack of "git diff --no-index". Rather use test_cmp for that purpose. Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 435f65b370..8073a5a1f2 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -11,36 +11,36 @@ test_description='git apply --stat --summary test. test_expect_success \ 'rename' \ 'git apply --stat --summary <../t4100/t-apply-1.patch >current && - git diff ../t4100/t-apply-1.expect current' + test_cmp ../t4100/t-apply-1.expect current' test_expect_success \ 'copy' \ 'git apply --stat --summary <../t4100/t-apply-2.patch >current && - git diff ../t4100/t-apply-2.expect current' + test_cmp ../t4100/t-apply-2.expect current' test_expect_success \ 'rewrite' \ 'git apply --stat --summary <../t4100/t-apply-3.patch >current && - git diff ../t4100/t-apply-3.expect current' + test_cmp ../t4100/t-apply-3.expect current' test_expect_success \ 'mode' \ 'git apply --stat --summary <../t4100/t-apply-4.patch >current && - git diff ../t4100/t-apply-4.expect current' + test_cmp ../t4100/t-apply-4.expect current' test_expect_success \ 'non git' \ 'git apply --stat --summary <../t4100/t-apply-5.patch >current && - git diff ../t4100/t-apply-5.expect current' + test_cmp ../t4100/t-apply-5.expect current' test_expect_success \ 'non git' \ 'git apply --stat --summary <../t4100/t-apply-6.patch >current && - git diff ../t4100/t-apply-6.expect current' + test_cmp ../t4100/t-apply-6.expect current' test_expect_success \ 'non git' \ 'git apply --stat --summary <../t4100/t-apply-7.patch >current && - git diff ../t4100/t-apply-7.expect current' + test_cmp ../t4100/t-apply-7.expect current' test_done -- cgit v1.2.3 From c14b9d1e330a7f68ffd0ad7e22d6148c6097c122 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 27 Jun 2008 18:43:09 +0100 Subject: Allow git-apply to recount the lines in a hunk (AKA recountdiff) Sometimes, the easiest way to fix up a patch is to edit it directly, even adding or deleting lines. Now, many people are not as divine as certain benevolent dictators as to update the hunk headers correctly at the first try. So teach the tool to do it for us. [jc: with tests] Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 62 ++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 8073a5a1f2..be837bb98d 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -3,44 +3,36 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git apply --stat --summary test. +test_description='git apply --stat --summary test, with --recount ' . ./test-lib.sh -test_expect_success \ - 'rename' \ - 'git apply --stat --summary <../t4100/t-apply-1.patch >current && - test_cmp ../t4100/t-apply-1.expect current' - -test_expect_success \ - 'copy' \ - 'git apply --stat --summary <../t4100/t-apply-2.patch >current && - test_cmp ../t4100/t-apply-2.expect current' - -test_expect_success \ - 'rewrite' \ - 'git apply --stat --summary <../t4100/t-apply-3.patch >current && - test_cmp ../t4100/t-apply-3.expect current' - -test_expect_success \ - 'mode' \ - 'git apply --stat --summary <../t4100/t-apply-4.patch >current && - test_cmp ../t4100/t-apply-4.expect current' - -test_expect_success \ - 'non git' \ - 'git apply --stat --summary <../t4100/t-apply-5.patch >current && - test_cmp ../t4100/t-apply-5.expect current' - -test_expect_success \ - 'non git' \ - 'git apply --stat --summary <../t4100/t-apply-6.patch >current && - test_cmp ../t4100/t-apply-6.expect current' - -test_expect_success \ - 'non git' \ - 'git apply --stat --summary <../t4100/t-apply-7.patch >current && - test_cmp ../t4100/t-apply-7.expect current' +UNC='s/^\(@@ -[1-9][0-9]*\),[0-9]* \(+[1-9][0-9]*\),[0-9]* @@/\1,999 \2,999 @@/' + +num=0 +while read title +do + num=$(( $num + 1 )) + test_expect_success "$title" ' + git apply --stat --summary \ + <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && + test_cmp ../t4100/t-apply-$num.expect current + ' + + test_expect_success "$title with recount" ' + sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | + git apply --recount --stat --summary >current && + test_cmp ../t4100/t-apply-$num.expect current + ' +done <<\EOF +rename +copy +rewrite +mode +non git (1) +non git (2) +non git (3) +EOF test_done -- cgit v1.2.3 From 6cf91492d9cd985e1fa65181d99d6d578d4439dc Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Fri, 4 Jul 2008 21:10:14 +0200 Subject: Fix apply --recount handling of no-EOL line If a patch modifies the last line of a file that previously had no terminating '\n', it looks like -old text \ No newline at end of file +new text Hence, a '\' line does not signal the end of the hunk. This modifies 'git apply --recount' to take this into account. Signed-off-by: Thomas Rast Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index be837bb98d..e0c67740a5 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -33,6 +33,8 @@ mode non git (1) non git (2) non git (3) +incomplete (1) +incomplete (2) EOF test_done -- cgit v1.2.3 From bfdbee98109c5ad2dbbc392e7eed1ae688acc039 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 8 Aug 2008 02:26:28 -0700 Subject: tests: use $TEST_DIRECTORY to refer to the t/ directory Many test scripts assumed that they will start in a 'trash' subdirectory that is a single level down from the t/ directory, and referred to their test vector files by asking for files like "../t9999/expect". This will break if we move the 'trash' subdirectory elsewhere. To solve this, we earlier introduced "$TEST_DIRECTORY" so that they can refer to t/ directory reliably. This finally makes all the tests use it to refer to the outside environment. With this patch, and a one-liner not included here (because it would contradict with what Dscho really wants to do): | diff --git a/t/test-lib.sh b/t/test-lib.sh | index 70ea7e0..60e69e4 100644 | --- a/t/test-lib.sh | +++ b/t/test-lib.sh | @@ -485,7 +485,7 @@ fi | . ../GIT-BUILD-OPTIONS | | # Test repository | -test="trash directory" | +test="trash directory/another level/yet another" | rm -fr "$test" || { | trap - exit | echo >&5 "FATAL: Cannot prepare test area" all the tests still pass, but we would want extra sets of eyeballs on this type of change to really make sure. [jc: with help from Stephan Beyer on http-push tests I do not run myself; credits for locating silly quoting errors go to Olivier Marin.] Signed-off-by: Junio C Hamano --- t/t4100-apply-stat.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t4100-apply-stat.sh') diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index e0c67740a5..9b433de836 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -17,13 +17,13 @@ do test_expect_success "$title" ' git apply --stat --summary \ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && - test_cmp ../t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' test_expect_success "$title with recount" ' sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | git apply --recount --stat --summary >current && - test_cmp ../t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' done <<\EOF rename -- cgit v1.2.3