Merge branch 'rj/cygwin-has-dev-tty'
[git/gitster.git] / t / t4064-diff-oidfind.sh
blob846f285f772e53abd13adce7add205d0a59c8d1f
1 #!/bin/sh
3 test_description='test finding specific blobs in the revision walking'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup ' '
9 git commit --allow-empty -m "empty initial commit" &&
11 echo "Hello, world!" >greeting &&
12 git add 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 &&
17 git add unrelated &&
18 git commit -m "unrelated history" &&
20 git revert HEAD^ &&
22 git commit --allow-empty -m "another unrelated commit"
25 test_expect_success 'find the greeting blob' '
26 cat >expect <<-EOF &&
27 Revert "add the greeting blob"
28 add the greeting blob
29 EOF
31 git log --format=%s --find-object=greeting^{blob} >actual &&
33 test_cmp expect actual
36 test_expect_success 'setup a tree' '
37 mkdir a &&
38 echo asdf >a/file &&
39 git add a/file &&
40 git commit -m "add a file in a subdirectory"
43 test_expect_success 'find a tree' '
44 cat >expect <<-EOF &&
45 add a file in a subdirectory
46 EOF
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' '
61 cat >expect <<-EOF &&
62 add sub
63 EOF
65 git log --format=%s --find-object=HEAD:sub >actual &&
67 test_cmp expect actual
70 test_expect_success 'set up merge tests' '
71 test_commit base &&
73 git checkout -b boring base^ &&
74 echo boring >file &&
75 git add file &&
76 git commit -m boring &&
78 git checkout -b interesting base^ &&
79 echo interesting >file &&
80 git add 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 &&
93 introduce blob
95 AM file
96 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 &&
103 echo boring >file &&
104 git commit -am "remove blob" &&
105 git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual &&
106 cat >expect <<-\EOF &&
107 remove blob
109 MA file
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 &&
119 untouched blob
122 test_cmp expect actual
125 test_done