diff --git a/builtin/log.c b/builtin/log.c index 5c9a8ef3632906..44e2399d596fe8 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -317,6 +317,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, if (rev->line_level_traverse && rev->prune_data.nr) die(_("-L: cannot be used with pathspec")); + if (rev->line_level_traverse && + (rev->diffopt.pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)) + die(_("-L does not yet support -G, -S, or --find-object")); + memset(&w, 0, sizeof(w)); userformat_find_requirements(NULL, &w); diff --git a/line-log.c b/line-log.c index 8bd422148dd492..d7d7ddb6af05f8 100644 --- a/line-log.c +++ b/line-log.c @@ -858,15 +858,29 @@ static void queue_diffs(struct line_log_data *range, diff_queue_clear(&diff_queued_diff); diff_tree_oid(parent_tree_oid, tree_oid, "", opt); if (opt->detect_rename && diff_might_be_rename()) { + struct diff_options rename_opts; + + /* + * Build a private diff_options for rename detection so + * that any user-specified options on the original opts + * (e.g. pickaxe) cannot discard diff pairs needed for + * rename tracking. Similar to blame's find_rename(). + */ + repo_diff_setup(opt->repo, &rename_opts); + rename_opts.flags.recursive = 1; + rename_opts.detect_rename = opt->detect_rename; + rename_opts.rename_score = opt->rename_score; + rename_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_setup_done(&rename_opts); + /* must look at the full tree diff to detect renames */ - clear_pathspec(&opt->pathspec); diff_queue_clear(&diff_queued_diff); - - diff_tree_oid(parent_tree_oid, tree_oid, "", opt); + diff_tree_oid(parent_tree_oid, tree_oid, "", &rename_opts); filter_diffs_for_paths(range, 1); - diffcore_std(opt); + diffcore_std(&rename_opts); filter_diffs_for_paths(range, 0); + diff_free(&rename_opts); } move_diff_queue(queue, &diff_queued_diff); } diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 0a7c3ca42f80fa..8ebc73d2d96c0c 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -367,4 +367,19 @@ test_expect_success 'show line-log with graph' ' test_cmp expect actual ' +test_expect_success '-L with -G is rejected' ' + test_must_fail git log -L 1,1:a.c -G "pattern" 2>err && + test_grep "does not yet support" err +' + +test_expect_success '-L with -S is rejected' ' + test_must_fail git log -L 1,1:a.c -S "pattern" 2>err && + test_grep "does not yet support" err +' + +test_expect_success '-L with --find-object is rejected' ' + test_must_fail git log -L 1,1:a.c --find-object=HEAD 2>err && + test_grep "does not yet support" err +' + test_done