@matheusbsbs / matheus-bagliano / commits / c63777c0d7
Fork 0

blame: -C -C -C

When you do this, existing "blame -C -C" would not find that the latter half of the file2 came from the existing file1: ... both file1 and file2 are tracked ... $ cat file1 >>file2 $ git add file1 file2 $ git commit This is because we avoid the expensive find-copies-harder code that makes unchanged file (in this case, file1) as a candidate for copy & paste source when annotating an existing file (file2). The third -C now allows it. However, this obviously makes the process very expensive. We've actually seen this patch before, but I dismissed it because it covers such a narrow (and arguably stupid) corner case. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed May 5, 2007 at 21:18 UTC c63777c0d7687a1edff2c0da307ad8ac1d75c8f6
1 file changed +13 -2
builtin-blame.c
+13 -2
@@ -55,6 +55,7 @@ static int num_commits;
55 #define PICKAXE_BLAME_MOVE 01
56 #define PICKAXE_BLAME_COPY 02
57 #define PICKAXE_BLAME_COPY_HARDER 04
58 +#define PICKAXE_BLAME_COPY_HARDEST 010
59
60 /*
61 * blame for a blame_entry with score lower than these thresholds
@@ -1079,8 +1080,9 @@ static int find_copy_in_parent(struct scoreboard *sb,
1080 * and this code needs to be after diff_setup_done(), which
1081 * usually makes find-copies-harder imply copy detection.
1082 */
1082 - if ((opt & PICKAXE_BLAME_COPY_HARDER) &&
1083 - (!porigin || strcmp(target->path, porigin->path)))
1083 + if ((opt & PICKAXE_BLAME_COPY_HARDEST)
1084 + || ((opt & PICKAXE_BLAME_COPY_HARDER)
1085 + && (!porigin || strcmp(target->path, porigin->path))))
1086 diff_opts.find_copies_harder = 1;
1087
1088 if (is_null_sha1(target->commit->object.sha1))
@@ -2127,6 +2129,15 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2129 blame_move_score = parse_score(arg+2);
2130 }
2131 else if (!prefixcmp(arg, "-C")) {
2132 + /*
2133 + * -C enables copy from removed files;
2134 + * -C -C enables copy from existing files, but only
2135 + * when blaming a new file;
2136 + * -C -C -C enables copy from existing files for
2137 + * everybody
2138 + */
2139 + if (opt & PICKAXE_BLAME_COPY_HARDER)
2140 + opt |= PICKAXE_BLAME_COPY_HARDEST;
2141 if (opt & PICKAXE_BLAME_COPY)
2142 opt |= PICKAXE_BLAME_COPY_HARDER;
2143 opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;