[PATCH] git-pickaxe -C -C -C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Three -C options makes the command to look for copied lines from _any_
existing file in the parent commit, not just changed files.

This is of course _very_ expensive.

Some numbers and observations.

* git-pickaxe -C revision.c
2.22user 0.02system 0:02.24elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+5263minor)pagefaults 0swaps
num read blob 486

* git-pickaxe -C -C -C revision.c
35.42user 0.27system 0:37.66elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (14major+115543minor)pagefaults 0swaps
num read blob 43277

Comparing the output from the above two, with this option, it
finds that some lines were copied from diff.c, diff-tree.c and
merge-cache.c; they are obvious patterns justifiably repeated.

 - list of parameters to a function (ll. 214-217, 247-249);

 - definitions of local variables (ll. 260-263);

 - loops over all cache entries (ll. 581-584).

This change probably falls into the category of "I did this not
because it is useful in practice but just because I could".

Nevertheless, looking at the output was very interesting.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---
 builtin-pickaxe.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin-pickaxe.c b/builtin-pickaxe.c
index f12b2d4..619a8c6 100644
--- a/builtin-pickaxe.c
+++ b/builtin-pickaxe.c
@@ -19,7 +19,7 @@
 #include <sys/time.h>
 
 static char pickaxe_usage[] =
-"git-pickaxe [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
+"git-pickaxe [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [-C] [commit] [--] file\n"
 "  -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
 "  -l, --long          Show long commit SHA1 (Default: off)\n"
 "  -t, --time          Show raw timestamp (Default: off)\n"
@@ -48,6 +48,7 @@ static int num_commits;
 #define PICKAXE_BLAME_MOVE		01
 #define PICKAXE_BLAME_COPY		02
 #define PICKAXE_BLAME_COPY_HARDER	04
+#define PICKAXE_BLAME_COPY_HARDEST	010
 
 /*
  * blame for a blame_entry with score lower than these thresholds
@@ -885,8 +886,9 @@ static int find_copy_in_parent(struct sc
 	 * and this code needs to be after diff_setup_done(), which
 	 * usually makes find-copies-harder imply copy detection.
 	 */
-	if ((opt & PICKAXE_BLAME_COPY_HARDER) &&
-	    (!porigin || strcmp(target->path, porigin->path)))
+	if (((opt & PICKAXE_BLAME_COPY_HARDER) &&
+	     (!porigin || strcmp(target->path, porigin->path))) ||
+	    (opt & PICKAXE_BLAME_COPY_HARDEST))
 		diff_opts.find_copies_harder = 1;
 
 	diff_tree_sha1(parent->tree->object.sha1,
@@ -1569,6 +1571,8 @@ int cmd_pickaxe(int argc, const char **a
 			blame_move_score = parse_score(arg+2);
 		}
 		else if (!strncmp("-C", arg, 2)) {
+			if (opt & PICKAXE_BLAME_COPY_HARDER)
+				opt |= PICKAXE_BLAME_COPY_HARDEST;
 			if (opt & PICKAXE_BLAME_COPY)
 				opt |= PICKAXE_BLAME_COPY_HARDER;
 			opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;
-- 
1.4.3.4.g9f05


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]