summaryrefslogtreecommitdiff
path: root/t/t4002-diff-basic.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t4002-diff-basic.sh')
-rwxr-xr-xt/t4002-diff-basic.sh247
1 files changed, 123 insertions, 124 deletions
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index cbcdd10..cb33070 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -6,12 +6,12 @@
test_description='Test diff raw-output.
'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh
-test_oid_init
-
test_oid_cache <<\EOF
aa_1 sha1:ccba72ad3888a3520b39efcf780b9ee64167535d
aa_1 sha256:9febfbf18197819b2735c45291f138525d2476d59470f98239647544586ba403
@@ -284,132 +284,131 @@ cmp_diff_files_output () {
test_cmp "$1" .test-tmp
}
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_O $tree_A >.test-a &&
- cmp -s .test-a .test-plain-OA'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_O $tree_A >.test-a &&
- cmp -s .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_O $tree_B >.test-a &&
- cmp -s .test-a .test-plain-OB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_O $tree_B >.test-a &&
- cmp -s .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree $tree_A $tree_B >.test-a &&
- cmp -s .test-a .test-plain-AB'
-
-test_expect_success \
- 'diff-tree of known trees.' \
- 'git diff-tree -r $tree_A $tree_B >.test-a &&
- cmp -s .test-a .test-recursive-AB'
-
-test_expect_success \
- 'diff-tree --stdin of known trees.' \
- 'echo $tree_A $tree_B | git diff-tree --stdin > .test-a &&
- echo $tree_A $tree_B > .test-plain-ABx &&
- cat .test-plain-AB >> .test-plain-ABx &&
- cmp -s .test-a .test-plain-ABx'
-
-test_expect_success \
- 'diff-tree --stdin of known trees.' \
- 'echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a &&
- echo $tree_A $tree_B > .test-recursive-ABx &&
- cat .test-recursive-AB >> .test-recursive-ABx &&
- cmp -s .test-a .test-recursive-ABx'
-
-test_expect_success \
- 'diff-cache O with A in cache' \
- 'git read-tree $tree_A &&
- git diff-index --cached $tree_O >.test-a &&
- cmp -s .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-cache O with B in cache' \
- 'git read-tree $tree_B &&
- git diff-index --cached $tree_O >.test-a &&
- cmp -s .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-cache A with B in cache' \
- 'git read-tree $tree_B &&
- git diff-index --cached $tree_A >.test-a &&
- cmp -s .test-a .test-recursive-AB'
-
-test_expect_success \
- 'diff-files with O in cache and A checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_A &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_O &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-OA'
-
-test_expect_success \
- 'diff-files with O in cache and B checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_B &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_O &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-OB'
-
-test_expect_success \
- 'diff-files with A in cache and B checked out' \
- 'rm -fr Z [A-Z][A-Z] &&
- git read-tree $tree_B &&
- git checkout-index -f -a &&
- git read-tree --reset $tree_A &&
- test_must_fail git update-index --refresh -q &&
- git diff-files >.test-a &&
- cmp_diff_files_output .test-a .test-recursive-AB'
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_O $tree_A >.test-a &&
+ cmp -s .test-a .test-plain-OA
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_O $tree_A >.test-a &&
+ cmp -s .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_O $tree_B >.test-a &&
+ cmp -s .test-a .test-plain-OB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_O $tree_B >.test-a &&
+ cmp -s .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree $tree_A $tree_B >.test-a &&
+ cmp -s .test-a .test-plain-AB
+'
+
+test_expect_success 'diff-tree of known trees.' '
+ git diff-tree -r $tree_A $tree_B >.test-a &&
+ cmp -s .test-a .test-recursive-AB
+'
+
+test_expect_success 'diff-tree --stdin of known trees.' '
+ echo $tree_A $tree_B | git diff-tree --stdin > .test-a &&
+ echo $tree_A $tree_B > .test-plain-ABx &&
+ cat .test-plain-AB >> .test-plain-ABx &&
+ cmp -s .test-a .test-plain-ABx
+'
+
+test_expect_success 'diff-tree --stdin of known trees.' '
+ echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a &&
+ echo $tree_A $tree_B > .test-recursive-ABx &&
+ cat .test-recursive-AB >> .test-recursive-ABx &&
+ cmp -s .test-a .test-recursive-ABx
+'
+
+test_expect_success 'diff-cache O with A in cache' '
+ git read-tree $tree_A &&
+ git diff-index --cached $tree_O >.test-a &&
+ cmp -s .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-cache O with B in cache' '
+ git read-tree $tree_B &&
+ git diff-index --cached $tree_O >.test-a &&
+ cmp -s .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-cache A with B in cache' '
+ git read-tree $tree_B &&
+ git diff-index --cached $tree_A >.test-a &&
+ cmp -s .test-a .test-recursive-AB
+'
+
+test_expect_success 'diff-files with O in cache and A checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_A &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_O &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-OA
+'
+
+test_expect_success 'diff-files with O in cache and B checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_B &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_O &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-OB
+'
+
+test_expect_success 'diff-files with A in cache and B checked out' '
+ rm -fr Z [A-Z][A-Z] &&
+ git read-tree $tree_B &&
+ git checkout-index -f -a &&
+ git read-tree --reset $tree_A &&
+ test_must_fail git update-index --refresh -q &&
+ git diff-files >.test-a &&
+ cmp_diff_files_output .test-a .test-recursive-AB
+'
################################################################
# Now we have established the baseline, we do not have to
# rely on individual object ID values that much.
-test_expect_success \
- 'diff-tree O A == diff-tree -R A O' \
- 'git diff-tree $tree_O $tree_A >.test-a &&
- git diff-tree -R $tree_A $tree_O >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree -r O A == diff-tree -r -R A O' \
- 'git diff-tree -r $tree_O $tree_A >.test-a &&
- git diff-tree -r -R $tree_A $tree_O >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree B A == diff-tree -R A B' \
- 'git diff-tree $tree_B $tree_A >.test-a &&
- git diff-tree -R $tree_A $tree_B >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff-tree -r B A == diff-tree -r -R A B' \
- 'git diff-tree -r $tree_B $tree_A >.test-a &&
- git diff-tree -r -R $tree_A $tree_B >.test-b &&
- cmp -s .test-a .test-b'
-
-test_expect_success \
- 'diff can read from stdin' \
- 'test_must_fail git diff --no-index -- MN - < NN |
- grep -v "^index" | sed "s#/-#/NN#" >.test-a &&
- test_must_fail git diff --no-index -- MN NN |
- grep -v "^index" >.test-b &&
- test_cmp .test-a .test-b'
+test_expect_success 'diff-tree O A == diff-tree -R A O' '
+ git diff-tree $tree_O $tree_A >.test-a &&
+ git diff-tree -R $tree_A $tree_O >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree -r O A == diff-tree -r -R A O' '
+ git diff-tree -r $tree_O $tree_A >.test-a &&
+ git diff-tree -r -R $tree_A $tree_O >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree B A == diff-tree -R A B' '
+ git diff-tree $tree_B $tree_A >.test-a &&
+ git diff-tree -R $tree_A $tree_B >.test-b &&
+ cmp -s .test-a .test-b
+'
+
+test_expect_success 'diff-tree -r B A == diff-tree -r -R A B' '
+ git diff-tree -r $tree_B $tree_A >.test-a &&
+ git diff-tree -r -R $tree_A $tree_B >.test-b &&
+ cmp -s .test-a .test-b'
+
+test_expect_success 'diff can read from stdin' '
+ test_must_fail git diff --no-index -- MN - < NN |
+ sed "/^index/d; s#/-#/NN#" >.test-a &&
+ test_must_fail git diff --no-index -- MN NN |
+ grep -v "^index" >.test-b &&
+ test_cmp .test-a .test-b
+'
test_done