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