Raw
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Bo Yang
4 #
5
6 test_description='Test --follow should always find copies hard in git log.
7
8 '
9
10 . ./test-lib.sh
11 . "$TEST_DIRECTORY"/lib-diff.sh
12
13 echo >path0 'Line 1
14 Line 2
15 Line 3
16 '
17
18 test_expect_success 'add a file path0 and commit.' '
19 git add path0 &&
20 git commit -m "Add path0"
21 '
22
23 echo >path0 'New line 1
24 New line 2
25 New line 3
26 '
27 test_expect_success 'Change path0.' '
28 git add path0 &&
29 git commit -m "Change path0"
30 '
31
32 cat <path0 >path1
33 test_expect_success 'copy path0 to path1.' '
34 git add path1 &&
35 git commit -m "Copy path1 from path0"
36 '
37
38 test_expect_success 'find the copy path0 -> path1 harder' '
39 git log --follow --name-status --pretty="format:%s" path1 > current
40 '
41
42 cat >expected <<\EOF
43 Copy path1 from path0
44 C100 path0 path1
45
46 Change path0
47 M path0
48
49 Add path0
50 A path0
51 EOF
52
53 test_expect_success 'validate the output.' '
54 compare_diff_patch current expected
55 '
56
57 test_expect_success 'log --follow -B does not BUG' '
58 git switch --orphan break_and_follow_are_icky_so_use_both &&
59
60 test_seq 1 127 >numbers &&
61 git add numbers &&
62 git commit -m "numbers" &&
63
64 printf "%s\n" A B C D E F G H I J K L M N O Q R S T U V W X Y Z >pool &&
65 echo changed >numbers &&
66 git add pool numbers &&
67 git commit -m "pool" &&
68
69 git log -1 -B --raw --follow -- "p*"
70 '
71
72 test_expect_success 'log --follow -B does not die or use uninitialized memory' '
73 printf "%s\n" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z >z &&
74 git add z &&
75 git commit -m "Initial" &&
76
77 test_seq 1 130 >z &&
78 echo lame >somefile &&
79 git add z somefile &&
80 git commit -m "Rewrite z, introduce lame somefile" &&
81
82 echo Content >somefile &&
83 git add somefile &&
84 git commit -m "Rewrite somefile" &&
85
86 git log -B --follow somefile
87 '
88
89 test_done