]>
Commit | Line | Data |
---|---|---|
15d061b4 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Rename interaction with pathspec. | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
10 | ||
11 | _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' | |
12 | _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" | |
ddafa7e9 | 13 | sanitize_diff_raw='s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]* / X X \1# /' |
15d061b4 JH |
14 | compare_diff_raw () { |
15 | # When heuristics are improved, the score numbers would change. | |
16 | # Ignore them while comparing. | |
17 | # Also we do not check SHA1 hash generation in this test, which | |
18 | # is a job for t0000-basic.sh | |
19 | ||
20 | sed -e "$sanitize_diff_raw" <"$1" >.tmp-1 | |
21 | sed -e "$sanitize_diff_raw" <"$2" >.tmp-2 | |
22 | diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 | |
23 | } | |
24 | ||
25 | test_expect_success \ | |
26 | 'prepare reference tree' \ | |
27 | 'mkdir path0 path1 && | |
28 | cp ../../COPYING path0/COPYING && | |
29 | git-update-cache --add path0/COPYING && | |
30 | tree=$(git-write-tree) && | |
31 | echo $tree' | |
32 | ||
33 | test_expect_success \ | |
34 | 'prepare work tree' \ | |
35 | 'cp path0/COPYING path1/COPYING && | |
36 | git-update-cache --add --remove path0/COPYING path1/COPYING' | |
37 | ||
38 | # In the tree, there is only path0/COPYING. In the cache, path0 and | |
39 | # path1 both have COPYING and the latter is a copy of path0/COPYING. | |
40 | # Comparing the full tree with cache should tell us so. | |
41 | ||
42 | git-diff-cache -C $tree >current | |
43 | ||
44 | cat >expected <<\EOF | |
45 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING | |
46 | EOF | |
47 | ||
48 | test_expect_success \ | |
6145ee8b | 49 | 'validate the result (#1)' \ |
15d061b4 JH |
50 | 'compare_diff_raw current expected' |
51 | ||
52 | # In the tree, there is only path0/COPYING. In the cache, path0 and | |
53 | # path1 both have COPYING and the latter is a copy of path0/COPYING. | |
6145ee8b JH |
54 | # However when we say we care only about path1, we should just see |
55 | # path1/COPYING suddenly appearing from nowhere, not detected as | |
56 | # a copy from path0/COPYING. | |
15d061b4 JH |
57 | |
58 | git-diff-cache -C $tree path1 >current | |
59 | ||
60 | cat >expected <<\EOF | |
6145ee8b | 61 | :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 N path1/COPYING |
15d061b4 JH |
62 | EOF |
63 | ||
64 | test_expect_success \ | |
6145ee8b | 65 | 'validate the result (#2)' \ |
15d061b4 JH |
66 | 'compare_diff_raw current expected' |
67 | ||
68 | test_expect_success \ | |
69 | 'tweak work tree' \ | |
70 | 'rm -f path0/COPYING && | |
71 | git-update-cache --remove path0/COPYING' | |
72 | ||
73 | # In the tree, there is only path0/COPYING. In the cache, path0 does | |
74 | # not have COPYING anymore and path1 has COPYING which is a copy of | |
75 | # path0/COPYING. Showing the full tree with cache should tell us about | |
76 | # the rename. | |
77 | ||
78 | git-diff-cache -C $tree >current | |
79 | ||
80 | cat >expected <<\EOF | |
81 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING | |
82 | EOF | |
83 | ||
84 | test_expect_success \ | |
6145ee8b | 85 | 'validate the result (#3)' \ |
15d061b4 JH |
86 | 'compare_diff_raw current expected' |
87 | ||
88 | # In the tree, there is only path0/COPYING. In the cache, path0 does | |
89 | # not have COPYING anymore and path1 has COPYING which is a copy of | |
6145ee8b JH |
90 | # path0/COPYING. When we say we care only about path1, we should just |
91 | # see path1/COPYING appearing from nowhere. | |
15d061b4 JH |
92 | |
93 | git-diff-cache -C $tree path1 >current | |
94 | ||
95 | cat >expected <<\EOF | |
6145ee8b | 96 | :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 N path1/COPYING |
15d061b4 JH |
97 | EOF |
98 | ||
99 | test_expect_success \ | |
6145ee8b | 100 | 'validate the result (#4)' \ |
15d061b4 JH |
101 | 'compare_diff_raw current expected' |
102 | ||
103 | test_done |