RelNotes: revert the description on the reverted topics
[git/debian.git] / t / t4063-diff-blobs.sh
blob7e6c9d638433caca632d0d6d6dbdbc8c1bd98ec8
1 #!/bin/sh
3 test_description='test direct comparison of blobs via git-diff'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 run_diff () {
9 # use full-index to make it easy to match the index line
10 git diff --full-index "$@" >diff
13 check_index () {
14 grep "^index $1\\.\\.$2" diff
17 check_mode () {
18 grep "^old mode $1" diff &&
19 grep "^new mode $2" diff
22 check_paths () {
23 grep "^diff --git a/$1 b/$2" diff
26 test_expect_success 'create some blobs' '
27 echo one >one &&
28 echo two >two &&
29 chmod +x two &&
30 git add . &&
32 # cover systems where modes are ignored
33 git update-index --chmod=+x two &&
35 git commit -m base &&
37 sha1_one=$(git rev-parse HEAD:one) &&
38 sha1_two=$(git rev-parse HEAD:two)
41 test_expect_success 'diff by sha1' '
42 run_diff $sha1_one $sha1_two
44 test_expect_success 'index of sha1 diff' '
45 check_index $sha1_one $sha1_two
47 test_expect_success 'sha1 diff uses arguments as paths' '
48 check_paths $sha1_one $sha1_two
50 test_expect_success 'sha1 diff has no mode change' '
51 ! grep mode diff
54 test_expect_success 'diff by tree:path (run)' '
55 run_diff HEAD:one HEAD:two
57 test_expect_success 'index of tree:path diff' '
58 check_index $sha1_one $sha1_two
60 test_expect_success 'tree:path diff uses filenames as paths' '
61 check_paths one two
63 test_expect_success 'tree:path diff shows mode change' '
64 check_mode 100644 100755
67 test_expect_success 'diff by ranged tree:path' '
68 run_diff HEAD:one..HEAD:two
70 test_expect_success 'index of ranged tree:path diff' '
71 check_index $sha1_one $sha1_two
73 test_expect_success 'ranged tree:path diff uses filenames as paths' '
74 check_paths one two
76 test_expect_success 'ranged tree:path diff shows mode change' '
77 check_mode 100644 100755
80 test_expect_success 'diff blob against file' '
81 run_diff HEAD:one two
83 test_expect_success 'index of blob-file diff' '
84 check_index $sha1_one $sha1_two
86 test_expect_success 'blob-file diff uses filename as paths' '
87 check_paths one two
89 test_expect_success FILEMODE 'blob-file diff shows mode change' '
90 check_mode 100644 100755
93 test_expect_success 'blob-file diff prefers filename to sha1' '
94 run_diff $sha1_one two &&
95 check_paths two two
98 test_done