Make git log --follow find copies among unmodified files.
'git log --follow <path>' don't track copies from unmodified files, and this patch fix it. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Bo Yang committed
May 6, 2010 at 21:52 UTC
0cdca133ec8aa10fe4c806f6695ccbf32394aa91
3 files changed
+58
-2
Documentation/git-log.txt
+1
-1
@@ -56,7 +56,7 @@ include::diff-options.txt[]
56
commits, and doesn't limit diff for those commits.
57
58
--follow::
59
- Continue listing the history of a file beyond renames.
59
+ Continue listing the history of a file beyond renames/copies.
60
61
--log-size::
62
Before the log message print out its size in bytes. Intended
t/t4205-log-follow-harder-copies.sh
new
+56
@@ -0,0 +1,56 @@
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
+. ./test-lib.sh
10
+. "$TEST_DIRECTORY"/diff-lib.sh
11
+
12
+echo >path0 'Line 1
13
+Line 2
14
+Line 3
15
+'
16
+
17
+test_expect_success \
18
+ 'add a file path0 and commit.' \
19
+ 'git add path0 &&
20
+ git commit -m "Add path0"'
21
+
22
+echo >path0 'New line 1
23
+New line 2
24
+New line 3
25
+'
26
+test_expect_success \
27
+ 'Change path0.' \
28
+ 'git add path0 &&
29
+ git commit -m "Change path0"'
30
+
31
+cat <path0 >path1
32
+test_expect_success \
33
+ 'copy path0 to path1.' \
34
+ 'git add path1 &&
35
+ git commit -m "Copy path1 from path0"'
36
+
37
+test_expect_success \
38
+ 'find the copy path0 -> path1 harder' \
39
+ 'git log --follow --name-status --pretty="format:%s" path1 > current'
40
+
41
+cat >expected <<\EOF
42
+Copy path1 from path0
43
+C100 path0 path1
44
+
45
+Change path0
46
+M path0
47
+
48
+Add path0
49
+A path0
50
+EOF
51
+
52
+test_expect_success \
53
+ 'validate the output.' \
54
+ 'compare_diff_patch current expected'
55
+
56
+test_done
tree-diff.c
+1
-1
@@ -346,7 +346,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
346
347
diff_setup(&diff_opts);
348
DIFF_OPT_SET(&diff_opts, RECURSIVE);
349
- diff_opts.detect_rename = DIFF_DETECT_RENAME;
349
+ DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
350
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
351
diff_opts.single_follow = opt->paths[0];
352
diff_opts.break_opt = opt->break_opt;