3 test_description
='test finding specific blobs in the revision walking'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup ' '
9 git commit --allow-empty -m "empty initial commit" &&
11 echo "Hello, world!" >greeting &&
13 git commit -m "add the greeting blob" && # borrowed from Git from the Bottom Up
14 git tag -m "the blob" greeting $(git rev-parse HEAD:greeting) &&
16 echo asdf >unrelated &&
18 git commit -m "unrelated history" &&
22 git commit --allow-empty -m "another unrelated commit"
25 test_expect_success
'find the greeting blob' '
27 Revert "add the greeting blob"
31 git log --format=%s --find-object=greeting^{blob} >actual &&
33 test_cmp expect actual
36 test_expect_success
'setup a tree' '
40 git commit -m "add a file in a subdirectory"
43 test_expect_success
'find a tree' '
45 add a file in a subdirectory
48 git log --format=%s -t --find-object=HEAD:a >actual &&
50 test_cmp expect actual
53 test_expect_success
'setup a submodule' '
54 test_create_repo sub &&
55 test_commit -C sub sub &&
56 git submodule add ./sub sub &&
57 git commit -a -m "add sub"
60 test_expect_success
'find a submodule' '
65 git log --format=%s --find-object=HEAD:sub >actual &&
67 test_cmp expect actual
70 test_expect_success
'set up merge tests' '
73 git checkout -b boring base^ &&
76 git commit -m boring &&
78 git checkout -b interesting base^ &&
79 echo interesting >file &&
81 git commit -m interesting &&
83 blob=$(git rev-parse interesting:file)
86 test_expect_success
'detect merge which introduces blob' '
87 git checkout -B merge base &&
88 git merge --no-commit boring &&
89 echo interesting >file &&
90 git commit -am "introduce blob" &&
91 git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual &&
92 cat >expect <<-\EOF &&
97 test_cmp expect actual
100 test_expect_success
'detect merge which removes blob' '
101 git checkout -B merge interesting &&
102 git merge --no-commit base &&
104 git commit -am "remove blob" &&
105 git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual &&
106 cat >expect <<-\EOF &&
111 test_cmp expect actual
114 test_expect_success
'do not detect merge that does not touch blob' '
115 git checkout -B merge interesting &&
116 git merge -m "untouched blob" base &&
117 git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual &&
118 cat >expect <<-\EOF &&
122 test_cmp expect actual