]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4005-diff-rename-2.sh
git-apply: parse the diff headers (both traditional and new)
[thirdparty/git.git] / t / t4005-diff-rename-2.sh
CommitLineData
f7c1512a
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Same rename detection as t4003 but testing diff-raw.
7
8'
9. ./test-lib.sh
10
11test_expect_success \
12 'prepare reference tree' \
13 'cat ../../COPYING >COPYING &&
14 echo frotz >rezrov &&
15 git-update-cache --add COPYING rezrov &&
16 tree=$(git-write-tree) &&
17 echo $tree'
18
19test_expect_success \
20 'prepare work tree' \
21 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
22 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
23 rm -f COPYING &&
24 git-update-cache --add --remove COPYING COPYING.?'
25
26# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
27# both are slightly edited, and unchanged rezrov. We say COPYING.1
28# and COPYING.2 are based on COPYING, and do not say anything about
29# rezrov.
30
31git-diff-cache -M $tree >current
32
33cat >expected <<\EOF
34:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 COPYING COPYING.1
35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 COPYING COPYING.2
36EOF
37
38test_expect_success \
39 'validate output from rename/copy detection' \
40 'diff -u current expected'
41
42test_expect_success \
43 'prepare work tree again' \
44 'mv COPYING.2 COPYING &&
45 git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
46
47# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
48# both are slightly edited, and unchanged rezrov. We say COPYING.1
49# is based on COPYING and COPYING is still there, and do not say anything
50# about rezrov.
51
52git-diff-cache -C $tree >current
53cat >expected <<\EOF
54:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 COPYING COPYING.1
55:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 COPYING COPYING
56EOF
57
58test_expect_success \
59 'validate output from rename/copy detection' \
60 'diff -u current expected'
61
62test_expect_success \
63 'prepare work tree once again' \
64 'cat ../../COPYING >COPYING &&
65 git-update-cache --add --remove COPYING COPYING.1'
66
67# tree has COPYING and rezrov. work tree has the same COPYING and
68# copy-edited COPYING.1, and unchanged rezrov. We should see
69# unmodified COPYING in the output, so that downstream diff-helper can
70# notice. We should not say anything about rezrov.
71
72git-diff-cache -C $tree >current
73cat >expected <<\EOF
74:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 COPYING COPYING.1
75:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 COPYING COPYING
76EOF
77
78test_expect_success \
79 'validate output from rename/copy detection' \
80 'diff -u current expected'
81
82test_done