summaryrefslogtreecommitdiff
path: root/line-log.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-08-21 11:04:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-21 17:17:52 (GMT)
commiteef5204190e6b99c9d3694fc416bd031cf253490 (patch)
tree165a885f7afc020eb5e28ff0f7cf9076978fea51 /line-log.c
parent75b2f01a0f642b39b0f29b6218515df9b5eb798e (diff)
downloadgit-eef5204190e6b99c9d3694fc416bd031cf253490.zip
git-eef5204190e6b99c9d3694fc416bd031cf253490.tar.gz
git-eef5204190e6b99c9d3694fc416bd031cf253490.tar.bz2
line-log: extract pathspec parsing from line ranges into a helper function
A helper function to parse the paths involved in the line ranges and to turn them into a pathspec will be useful in the next patch. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/line-log.c b/line-log.c
index 0a17b21..93f4e10 100644
--- a/line-log.c
+++ b/line-log.c
@@ -736,6 +736,22 @@ static struct line_log_data *lookup_line_range(struct rev_info *revs,
return ret;
}
+static void parse_pathspec_from_ranges(struct pathspec *pathspec,
+ struct line_log_data *range)
+{
+ struct line_log_data *r;
+ struct argv_array array = ARGV_ARRAY_INIT;
+ const char **paths;
+
+ for (r = range; r; r = r->next)
+ argv_array_push(&array, r->path);
+ paths = argv_array_detach(&array);
+
+ parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL, "", paths);
+ /* strings are now owned by pathspec */
+ free(paths);
+}
+
void line_log_init(struct rev_info *rev, const char *prefix, struct string_list *args)
{
struct commit *commit = NULL;
@@ -745,20 +761,8 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
range = parse_lines(rev->diffopt.repo, commit, prefix, args);
add_line_range(rev, commit, range);
- if (!rev->diffopt.detect_rename) {
- struct line_log_data *r;
- struct argv_array array = ARGV_ARRAY_INIT;
- const char **paths;
-
- for (r = range; r; r = r->next)
- argv_array_push(&array, r->path);
- paths = argv_array_detach(&array);
-
- parse_pathspec(&rev->diffopt.pathspec, 0,
- PATHSPEC_PREFER_FULL, "", paths);
- /* strings are now owned by pathspec */
- free(paths);
- }
+ if (!rev->diffopt.detect_rename)
+ parse_pathspec_from_ranges(&rev->diffopt.pathspec, range);
}
static void move_diff_queue(struct diff_queue_struct *dst,