Code

Merge branch 'master' of git://repo.or.cz/git-gui
[git.git] / t / t4007-rename-3.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
6 test_description='Rename interaction with pathspec.
8 '
9 . ./test-lib.sh
10 . ../diff-lib.sh ;# test-lib chdir's into trash
12 test_expect_success \
13     'prepare reference tree' \
14     'mkdir path0 path1 &&
15      cp ../../COPYING path0/COPYING &&
16      git update-index --add path0/COPYING &&
17     tree=$(git write-tree) &&
18     echo $tree'
20 test_expect_success \
21     'prepare work tree' \
22     'cp path0/COPYING path1/COPYING &&
23      git update-index --add --remove path0/COPYING path1/COPYING'
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.
29 git diff-index -C --find-copies-harder $tree >current
31 cat >expected <<\EOF
32 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100   path0/COPYING   path1/COPYING
33 EOF
35 test_expect_success \
36     'validate the result (#1)' \
37     'compare_diff_raw current expected'
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.
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.
45 git diff-index -C $tree path1 >current
47 cat >expected <<\EOF
48 :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A      path1/COPYING
49 EOF
51 test_expect_success \
52     'validate the result (#2)' \
53     'compare_diff_raw current expected'
55 test_expect_success \
56     'tweak work tree' \
57     'rm -f path0/COPYING &&
58      git update-index --remove path0/COPYING'
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.
65 git diff-index -C $tree >current
67 cat >expected <<\EOF
68 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100   path0/COPYING   path1/COPYING
69 EOF
71 test_expect_success \
72     'validate the result (#3)' \
73     'compare_diff_raw current expected'
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
77 # path0/COPYING.  When we say we care only about path1, we should just
78 # see path1/COPYING appearing from nowhere.
80 git diff-index -C $tree path1 >current
82 cat >expected <<\EOF
83 :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A      path1/COPYING
84 EOF
86 test_expect_success \
87     'validate the result (#4)' \
88     'compare_diff_raw current expected'
90 test_done