blob: 82ae8d98a403bb644eede373a8def1a37a811fdd [file] [log] [blame]
Thomas Rast12da1d12013-03-28 17:47:32 +01001#ifndef LINE_LOG_H
2#define LINE_LOG_H
3
4#include "diffcore.h"
5
6struct rev_info;
7struct commit;
8
9/* A range [start,end]. Lines are numbered starting at 0, and the
10 * ranges include start but exclude end. */
11struct range {
12 long start, end;
13};
14
15/* A set of ranges. The ranges must always be disjoint and sorted. */
16struct range_set {
Ramsay Jones071bcaa2017-09-21 17:49:38 +010017 unsigned int alloc, nr;
Thomas Rast12da1d12013-03-28 17:47:32 +010018 struct range *ranges;
19};
20
21/* A diff, encoded as the set of pre- and post-image ranges where the
22 * files differ. A pair of ranges corresponds to a hunk. */
23struct diff_ranges {
24 struct range_set parent;
25 struct range_set target;
26};
27
Denton Liu55454422019-04-29 04:28:14 -040028void range_set_init(struct range_set *, size_t prealloc);
29void range_set_release(struct range_set *);
Eric Sunshinec0babbe2013-08-06 09:59:36 -040030/* Range includes start; excludes end */
Denton Liu55454422019-04-29 04:28:14 -040031void range_set_append_unsafe(struct range_set *, long start, long end);
Eric Sunshinec0babbe2013-08-06 09:59:36 -040032/* New range must begin at or after end of last added range */
Denton Liu55454422019-04-29 04:28:14 -040033void range_set_append(struct range_set *, long start, long end);
Eric Sunshinec0babbe2013-08-06 09:59:36 -040034/*
35 * In-place pass of sorting and merging the ranges in the range set,
36 * to sort and make the ranges disjoint.
37 */
Denton Liu55454422019-04-29 04:28:14 -040038void sort_and_merge_range_set(struct range_set *);
Eric Sunshinec0babbe2013-08-06 09:59:36 -040039
Thomas Rast12da1d12013-03-28 17:47:32 +010040/* Linked list of interesting files and their associated ranges. The
Thomas Rast31c61912013-04-12 18:05:11 +020041 * list must be kept sorted by path.
42 *
43 * For simplicity, even though this is highly redundant, each
44 * line_log_data owns its 'path'.
45 */
Thomas Rast12da1d12013-03-28 17:47:32 +010046struct line_log_data {
47 struct line_log_data *next;
Thomas Rast31c61912013-04-12 18:05:11 +020048 char *path;
Thomas Rast12da1d12013-03-28 17:47:32 +010049 struct range_set ranges;
Thomas Rast12da1d12013-03-28 17:47:32 +010050 struct diff_filepair *pair;
51 struct diff_ranges diff;
52};
53
Denton Liu55454422019-04-29 04:28:14 -040054void line_log_init(struct rev_info *rev, const char *prefix, struct string_list *args);
Thomas Rast12da1d12013-03-28 17:47:32 +010055
Denton Liu55454422019-04-29 04:28:14 -040056int line_log_filter(struct rev_info *rev);
SZEDER Gábor3cb9d2b2020-05-11 11:56:17 +000057int line_log_process_ranges_arbitrary_commit(struct rev_info *rev,
58 struct commit *commit);
Thomas Rast12da1d12013-03-28 17:47:32 +010059
Denton Liu55454422019-04-29 04:28:14 -040060int line_log_print(struct rev_info *rev, struct commit *commit);
Thomas Rast12da1d12013-03-28 17:47:32 +010061
62#endif /* LINE_LOG_H */