]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4007-rename-3.sh
Rewrite "git-frotz" to "git frotz"
[thirdparty/git.git] / t / t4007-rename-3.sh
CommitLineData
15d061b4
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Rename interaction with pathspec.
7
8'
9. ./test-lib.sh
edb0c724 10. ../diff-lib.sh ;# test-lib chdir's into trash
15d061b4
JH
11
12test_expect_success \
13 'prepare reference tree' \
14 'mkdir path0 path1 &&
15 cp ../../COPYING path0/COPYING &&
5be60078
JH
16 git update-index --add path0/COPYING &&
17 tree=$(git write-tree) &&
15d061b4
JH
18 echo $tree'
19
20test_expect_success \
21 'prepare work tree' \
22 'cp path0/COPYING path1/COPYING &&
5be60078 23 git update-index --add --remove path0/COPYING path1/COPYING'
15d061b4
JH
24
25# In the tree, there is only path0/COPYING. In the cache, path0 and
26# path1 both have COPYING and the latter is a copy of path0/COPYING.
27# Comparing the full tree with cache should tell us so.
28
5be60078 29git diff-index -C --find-copies-harder $tree >current
15d061b4
JH
30
31cat >expected <<\EOF
32:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
33EOF
34
35test_expect_success \
6145ee8b 36 'validate the result (#1)' \
15d061b4
JH
37 'compare_diff_raw current expected'
38
39# In the tree, there is only path0/COPYING. In the cache, path0 and
40# path1 both have COPYING and the latter is a copy of path0/COPYING.
6145ee8b
JH
41# However when we say we care only about path1, we should just see
42# path1/COPYING suddenly appearing from nowhere, not detected as
43# a copy from path0/COPYING.
15d061b4 44
5be60078 45git diff-index -C $tree path1 >current
15d061b4
JH
46
47cat >expected <<\EOF
2bbcddee 48:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
15d061b4
JH
49EOF
50
51test_expect_success \
6145ee8b 52 'validate the result (#2)' \
15d061b4
JH
53 'compare_diff_raw current expected'
54
55test_expect_success \
56 'tweak work tree' \
57 'rm -f path0/COPYING &&
5be60078 58 git update-index --remove path0/COPYING'
15d061b4
JH
59
60# In the tree, there is only path0/COPYING. In the cache, path0 does
61# not have COPYING anymore and path1 has COPYING which is a copy of
62# path0/COPYING. Showing the full tree with cache should tell us about
63# the rename.
64
5be60078 65git diff-index -C $tree >current
15d061b4
JH
66
67cat >expected <<\EOF
68:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING
69EOF
70
71test_expect_success \
6145ee8b 72 'validate the result (#3)' \
15d061b4
JH
73 'compare_diff_raw current expected'
74
75# In the tree, there is only path0/COPYING. In the cache, path0 does
76# not have COPYING anymore and path1 has COPYING which is a copy of
6145ee8b
JH
77# path0/COPYING. When we say we care only about path1, we should just
78# see path1/COPYING appearing from nowhere.
15d061b4 79
5be60078 80git diff-index -C $tree path1 >current
15d061b4
JH
81
82cat >expected <<\EOF
2bbcddee 83:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
15d061b4
JH
84EOF
85
86test_expect_success \
6145ee8b 87 'validate the result (#4)' \
15d061b4
JH
88 'compare_diff_raw current expected'
89
90test_done