Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='Rename interaction with pathspec. |
| 7 | |
| 8 | ' |
| 9 | . ./test-lib.sh |
Junio C Hamano | bfdbee9 | 2008-08-08 02:26:28 -0700 | [diff] [blame] | 10 | . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 11 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 12 | test_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 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 19 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 20 | test_expect_success 'prepare work tree' ' |
| 21 | cp path0/COPYING path1/COPYING && |
| 22 | git update-index --add --remove path0/COPYING path1/COPYING |
| 23 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 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 | |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 29 | cat >expected <<\EOF |
| 30 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING |
| 31 | EOF |
| 32 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 33 | test_expect_success 'copy detection' ' |
| 34 | git diff-index -C --find-copies-harder $tree >current && |
| 35 | compare_diff_raw current expected |
| 36 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 37 | |
Junio C Hamano | a0919ce | 2009-05-22 23:14:25 -0700 | [diff] [blame] | 38 | test_expect_success 'copy detection, cached' ' |
| 39 | git diff-index -C --find-copies-harder --cached $tree >current && |
| 40 | compare_diff_raw current expected |
| 41 | ' |
| 42 | |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 43 | # In the tree, there is only path0/COPYING. In the cache, path0 and |
| 44 | # path1 both have COPYING and the latter is a copy of path0/COPYING. |
Junio C Hamano | 6145ee8 | 2005-05-27 15:56:17 -0700 | [diff] [blame] | 45 | # However when we say we care only about path1, we should just see |
| 46 | # path1/COPYING suddenly appearing from nowhere, not detected as |
| 47 | # a copy from path0/COPYING. |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 48 | |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 49 | cat >expected <<\EOF |
Junio C Hamano | 2bbcdde | 2005-07-26 00:22:43 -0700 | [diff] [blame] | 50 | :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 51 | EOF |
| 52 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 53 | test_expect_success 'copy, limited to a subtree' ' |
| 54 | git diff-index -C --find-copies-harder $tree path1 >current && |
| 55 | compare_diff_raw current expected |
| 56 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 57 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 58 | test_expect_success 'tweak work tree' ' |
| 59 | rm -f path0/COPYING && |
| 60 | git update-index --remove path0/COPYING |
| 61 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 62 | # In the tree, there is only path0/COPYING. In the cache, path0 does |
| 63 | # not have COPYING anymore and path1 has COPYING which is a copy of |
| 64 | # path0/COPYING. Showing the full tree with cache should tell us about |
| 65 | # the rename. |
| 66 | |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 67 | cat >expected <<\EOF |
| 68 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING |
| 69 | EOF |
| 70 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 71 | test_expect_success 'rename detection' ' |
| 72 | git diff-index -C --find-copies-harder $tree >current && |
| 73 | compare_diff_raw current expected |
| 74 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 75 | |
| 76 | # In the tree, there is only path0/COPYING. In the cache, path0 does |
| 77 | # not have COPYING anymore and path1 has COPYING which is a copy of |
Junio C Hamano | 6145ee8 | 2005-05-27 15:56:17 -0700 | [diff] [blame] | 78 | # path0/COPYING. When we say we care only about path1, we should just |
| 79 | # see path1/COPYING appearing from nowhere. |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 80 | |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 81 | cat >expected <<\EOF |
Junio C Hamano | 2bbcdde | 2005-07-26 00:22:43 -0700 | [diff] [blame] | 82 | :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 83 | EOF |
| 84 | |
Junio C Hamano | aceae2e | 2009-05-22 23:06:58 -0700 | [diff] [blame] | 85 | test_expect_success 'rename, limited to a subtree' ' |
| 86 | git diff-index -C --find-copies-harder $tree path1 >current && |
| 87 | compare_diff_raw current expected |
| 88 | ' |
Junio C Hamano | 15d061b | 2005-05-27 15:55:55 -0700 | [diff] [blame] | 89 | |
| 90 | test_done |