Git fork
1#!/bin/sh
2
3test_description='test unique sha1 abbreviation on "index from..to" line'
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 test_oid_cache <<-EOF &&
9 val1 sha1:4827
10 val1 sha256:5664
11
12 val2 sha1:11742
13 val2 sha256:10625
14
15 hash1 sha1:51d2738463ea4ca66f8691c91e33ce64b7d41bb1
16 hash1 sha256:ae31dfff0af93b2c62b0098a039b38569c43b0a7e97b873000ca42d128f27350
17
18 hasht1 sha1:51d27384
19 hasht1 sha256:ae31dfff
20
21 hash2 sha1:51d2738efb4ad8a1e40bed839ab8e116f0a15e47
22 hash2 sha256:ae31dffada88a46fd5f53c7ed5aa25a7a8951f1d5e88456c317c8d5484d263e5
23
24 hasht2 sha1:51d2738e
25 hasht2 sha256:ae31dffa
26 EOF
27
28 cat >expect_initial <<-EOF &&
29 100644 blob $(test_oid hash1) foo
30 EOF
31
32 cat >expect_update <<-EOF &&
33 100644 blob $(test_oid hash2) foo
34 EOF
35
36 test_oid val1 > foo &&
37 git add foo &&
38 git commit -m "initial" &&
39 git cat-file -p HEAD: > actual &&
40 test_cmp expect_initial actual &&
41 test_oid val2 > foo &&
42 git commit -a -m "update" &&
43 git cat-file -p HEAD: > actual &&
44 test_cmp expect_update actual
45'
46
47cat >expect <<EOF
48index $(test_oid hasht1)..$(test_oid hasht2) 100644
49EOF
50
51test_expect_success 'diff does not produce ambiguous index line' '
52 git diff HEAD^..HEAD | grep index > actual &&
53 test_cmp expect actual
54'
55
56test_done