From 9eac5954e81037f282ace2efff7110af3440dc19 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 1 Jun 2023 13:41:06 -0400 Subject: diff: factor out --follow pathspec check In --follow mode, we require exactly one pathspec. We check this condition in two places: - in diff_setup_done(), we complain if --follow is used with an inapropriate pathspec - in git-log's revision "tweak" function, we enable log.follow only if the pathspec allows it The duplication isn't a big deal right now, since the logic is so simple. But in preparation for it becoming more complex, let's pull it into a shared function. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/log.c b/builtin/log.c index a70fba198f..06e3a1a946 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -856,7 +856,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev, struct setup_revision_opt *opt) { if (rev->diffopt.flags.default_follow_renames && - rev->prune_data.nr == 1) + diff_check_follow_pathspec(&rev->prune_data, 0)) rev->diffopt.flags.follow_renames = 1; if (rev->first_parent_only) -- cgit v1.3-5-g9baa