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 10. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash 11 12test_expect_success 'prepare reference tree'' 13 mkdir path0 path1 && 14 cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && 15 git update-index --add path0/COPYING && 16 tree=$(git write-tree)&& 17 echo$tree 18' 19 20test_expect_success 'prepare work tree'' 21 cp path0/COPYING path1/COPYING && 22 git update-index --add --remove path0/COPYING path1/COPYING 23' 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 29cat>expected <<\EOF 30:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING 31EOF 32 33test_expect_success 'copy detection'' 34 git diff-index -C --find-copies-harder$tree>current && 35 compare_diff_raw current expected 36' 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# However when we say we care only about path1, we should just see 41# path1/COPYING suddenly appearing from nowhere, not detected as 42# a copy from path0/COPYING. 43 44cat>expected <<\EOF 45:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING 46EOF 47 48test_expect_success 'copy, limited to a subtree'' 49 git diff-index -C --find-copies-harder$treepath1 >current && 50 compare_diff_raw current expected 51' 52 53test_expect_success 'tweak work tree'' 54 rm -f path0/COPYING && 55 git update-index --remove path0/COPYING 56' 57# In the tree, there is only path0/COPYING. In the cache, path0 does 58# not have COPYING anymore and path1 has COPYING which is a copy of 59# path0/COPYING. Showing the full tree with cache should tell us about 60# the rename. 61 62cat>expected <<\EOF 63:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING 64EOF 65 66test_expect_success 'rename detection'' 67 git diff-index -C --find-copies-harder$tree>current && 68 compare_diff_raw current expected 69' 70 71# In the tree, there is only path0/COPYING. In the cache, path0 does 72# not have COPYING anymore and path1 has COPYING which is a copy of 73# path0/COPYING. When we say we care only about path1, we should just 74# see path1/COPYING appearing from nowhere. 75 76cat>expected <<\EOF 77:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING 78EOF 79 80test_expect_success 'rename, limited to a subtree'' 81 git diff-index -C --find-copies-harder$treepath1 >current && 82 compare_diff_raw current expected 83' 84 85test_done