]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4003-diff-rename-1.sh
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / t / t4003-diff-rename-1.sh
CommitLineData
427dcb4b
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='More rename detection
7
8'
16d4bd4f
ÆAB
9
10TEST_PASSES_SANITIZE_LEAK=true
427dcb4b 11. ./test-lib.sh
ebd73f50 12. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
b6d8f309 13
427dcb4b
JH
14test_expect_success \
15 'prepare reference tree' \
15b808da 16 'COPYING_test_data >COPYING &&
f7c1512a 17 echo frotz >rezrov &&
5be60078
JH
18 git update-index --add COPYING rezrov &&
19 tree=$(git write-tree) &&
427dcb4b
JH
20 echo $tree'
21
22test_expect_success \
23 'prepare work tree' \
24 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
25 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
26 rm -f COPYING &&
5be60078 27 git update-index --add --remove COPYING COPYING.?'
427dcb4b 28
f7c1512a
JH
29# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
30# both are slightly edited, and unchanged rezrov. So we say you
31# copy-and-edit one, and rename-and-edit the other. We do not say
32# anything about rezrov.
c3e7fbcb 33
0940e5f2 34GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
427dcb4b 35cat >expected <<\EOF
b6d8f309 36diff --git a/COPYING b/COPYING.1
427dcb4b 37copy from COPYING
b6d8f309 38copy to COPYING.1
427dcb4b 39--- a/COPYING
b6d8f309
JH
40+++ b/COPYING.1
41@@ -6 +6 @@
42- HOWEVER, in order to allow a migration to GPLv3 if that seems like
43+ However, in order to allow a migration to GPLv3 if that seems like
44diff --git a/COPYING b/COPYING.2
dc938417
LT
45rename from COPYING
46rename to COPYING.2
427dcb4b 47--- a/COPYING
b6d8f309
JH
48+++ b/COPYING.2
49@@ -2 +2 @@
427dcb4b
JH
50- Note that the only valid version of the GPL as far as this project
51+ Note that the only valid version of the G.P.L as far as this project
b6d8f309
JH
52@@ -6 +6 @@
53- HOWEVER, in order to allow a migration to GPLv3 if that seems like
54+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
55@@ -12 +12 @@
56- This file is licensed under the GPL v2, or a later version
57+ This file is licensed under the G.P.L v2, or a later version
427dcb4b
JH
58EOF
59
60test_expect_success \
b6d8f309
JH
61 'validate output from rename/copy detection (#1)' \
62 'compare_diff_patch current expected'
427dcb4b
JH
63
64test_expect_success \
65 'prepare work tree again' \
66 'mv COPYING.2 COPYING &&
5be60078 67 git update-index --add --remove COPYING COPYING.1 COPYING.2'
c3e7fbcb 68
f7c1512a
JH
69# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
70# both are slightly edited, and unchanged rezrov. So we say you
71# edited one, and copy-and-edit the other. We do not say
72# anything about rezrov.
427dcb4b 73
5be60078 74GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
427dcb4b 75cat >expected <<\EOF
427dcb4b
JH
76diff --git a/COPYING b/COPYING
77--- a/COPYING
78+++ b/COPYING
b6d8f309 79@@ -2 +2 @@
427dcb4b
JH
80- Note that the only valid version of the GPL as far as this project
81+ Note that the only valid version of the G.P.L as far as this project
b6d8f309
JH
82@@ -6 +6 @@
83- HOWEVER, in order to allow a migration to GPLv3 if that seems like
84+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
85@@ -12 +12 @@
86- This file is licensed under the GPL v2, or a later version
87+ This file is licensed under the G.P.L v2, or a later version
25d5ea41
JH
88diff --git a/COPYING b/COPYING.1
89copy from COPYING
90copy to COPYING.1
91--- a/COPYING
92+++ b/COPYING.1
93@@ -6 +6 @@
94- HOWEVER, in order to allow a migration to GPLv3 if that seems like
95+ However, in order to allow a migration to GPLv3 if that seems like
427dcb4b
JH
96EOF
97
c3e7fbcb 98test_expect_success \
b6d8f309
JH
99 'validate output from rename/copy detection (#2)' \
100 'compare_diff_patch current expected'
c3e7fbcb
JH
101
102test_expect_success \
103 'prepare work tree once again' \
15b808da 104 'COPYING_test_data >COPYING &&
5be60078 105 git update-index --add --remove COPYING COPYING.1'
c3e7fbcb 106
f7c1512a
JH
107# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
108# but COPYING is not edited. We say you copy-and-edit COPYING.1; this
109# is only possible because -C mode now reports the unmodified file to
110# the diff-core. Unchanged rezrov, although being fed to
5be60078 111# git diff-index as well, should not be mentioned.
c3e7fbcb 112
4727f640 113GIT_DIFF_OPTS=--unified=0 \
5be60078 114 git diff-index -C --find-copies-harder -p $tree >current
c3e7fbcb 115cat >expected <<\EOF
b6d8f309 116diff --git a/COPYING b/COPYING.1
c3e7fbcb 117copy from COPYING
b6d8f309 118copy to COPYING.1
c3e7fbcb 119--- a/COPYING
b6d8f309
JH
120+++ b/COPYING.1
121@@ -6 +6 @@
122- HOWEVER, in order to allow a migration to GPLv3 if that seems like
123+ However, in order to allow a migration to GPLv3 if that seems like
c3e7fbcb
JH
124EOF
125
427dcb4b 126test_expect_success \
b6d8f309
JH
127 'validate output from rename/copy detection (#3)' \
128 'compare_diff_patch current expected'
427dcb4b
JH
129
130test_done