Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: git blame not respecting --find-copies-harder ?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:05
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Jeff King [off-list ref] writes:
On Wed, Jul 30, 2008 at 05:43:52PM +0200, Sverre Rabbelier wrote:
quoted
On Wed, Jul 30, 2008 at 17:01, Björn Steinbrink [off-list ref] wrote:
quoted
git blame doesn't know --find-copies-harder, it's -C -C for blame.
Shouldn't it have died with "don't know option --find-copies-harder" then?
Unfortunately, it _does_ know --find-copies-harder, because unknown
options get sent to the revision option parser, which chains to the diff
option parser. So it recognizes --find-copies-harder, but just sets a
flag that doesn't do what we expect.

I'm not sure if there is a simple fix. Does blame actually need the diff
option parsing? If not, then we might be able to pass a flag to
parse_revision_opt that says "don't do diff options, too".
Sigh...

We can probably pick up the result revision parser parsed out of
revs.diffopt, and then tweak "opt" with it, perhaps like this.

 builtin-blame.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 8b6b09b..4ea3431 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2346,6 +2346,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 parse_done:
 	argc = parse_options_end(&ctx);
 
+	if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
+		opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
+			PICKAXE_BLAME_COPY_HARDER);
+
 	if (!blame_move_score)
 		blame_move_score = BLAME_DEFAULT_MOVE_SCORE;
 	if (!blame_copy_score)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help