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 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" 13sanitize_diff_raw='s/ \('"$_x40"'\) \1 \([CR]\)[0-9]* / \1 \1 \2# /' 14compare_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 20sed-e"$sanitize_diff_raw"<"$1">.tmp-1 21sed-e"$sanitize_diff_raw"<"$2">.tmp-2 22diff-u .tmp-1 .tmp-2&&rm-f .tmp-1 .tmp-2 23} 24 25test_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 33test_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 42git-diff-cache -C$tree>current 43 44cat>expected <<\EOF 45:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING 46EOF 47 48test_expect_success \ 49'validate the result' \ 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. 54# When we omit output from path0 it should still be able to tell us 55# that path1/COPYING is result from a copy from path0/COPYING, not 56# rename, which would imply path0/COPYING is now gone. 57 58git-diff-cache -C$tree path1 >current 59 60cat>expected <<\EOF 61:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING 62EOF 63 64test_expect_success \ 65'validate the result' \ 66'compare_diff_raw current expected' 67 68test_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 78git-diff-cache -C$tree>current 79 80cat>expected <<\EOF 81:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING 82EOF 83 84test_expect_success \ 85'validate the result' \ 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 90# path0/COPYING. Even if we restrict the output to path1, it still 91# should show us the rename. 92 93git-diff-cache -C$tree path1 >current 94 95cat>expected <<\EOF 96:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING 97EOF 98 99test_expect_success \ 100'validate the result' \ 101'compare_diff_raw current expected' 102 103test_done