12da1d1f6f
This is a rewrite of much of Bo's work, mainly in an effort to split it into smaller, easier to understand routines. The algorithm is built around the struct range_set, which encodes a series of line ranges as intervals [a,b). This is used in two contexts: * A set of lines we are tracking (which will change as we dig through history). * To encode diffs, as pairs of ranges. The main routine is range_set_map_across_diff(). It processes the diff between a commit C and some parent P. It determines which diff hunks are relevant to the ranges tracked in C, and computes the new ranges for P. The algorithm is then simply to process history in topological order from newest to oldest, computing ranges and (partial) diffs. At branch points, we need to merge the ranges we are watching. We will find that many commits do not affect the chosen ranges, and mark them TREESAME (in addition to those already filtered by pathspec limiting). Another pass of history simplification then gets rid of such commits. This is wired as an extra filtering pass in the log machinery. This currently only reduces code duplication, but should allow for other simplifications and options to be used. Finally, we hook a diff printer into the output chain. Ideally we would wire directly into the diff logic, to optionally use features like word diff. However, that will require some major reworking of the diff chain, so we completely replace the output with our own diff for now. As this was a GSoC project, and has quite some history by now, many people have helped. In no particular order, thanks go to Jakub Narebski <jnareb@gmail.com> Jens Lehmann <Jens.Lehmann@web.de> Jonathan Nieder <jrnieder@gmail.com> Junio C Hamano <gitster@pobox.com> Ramsay Jones <ramsay@ramsay1.demon.co.uk> Will Palmer <wmpalmer@gmail.com> Apologies to everyone I forgot. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
#ifndef LINE_LOG_H
|
|
#define LINE_LOG_H
|
|
|
|
#include "diffcore.h"
|
|
|
|
struct rev_info;
|
|
struct commit;
|
|
|
|
/* A range [start,end]. Lines are numbered starting at 0, and the
|
|
* ranges include start but exclude end. */
|
|
struct range {
|
|
long start, end;
|
|
};
|
|
|
|
/* A set of ranges. The ranges must always be disjoint and sorted. */
|
|
struct range_set {
|
|
int alloc, nr;
|
|
struct range *ranges;
|
|
};
|
|
|
|
/* A diff, encoded as the set of pre- and post-image ranges where the
|
|
* files differ. A pair of ranges corresponds to a hunk. */
|
|
struct diff_ranges {
|
|
struct range_set parent;
|
|
struct range_set target;
|
|
};
|
|
|
|
/* Linked list of interesting files and their associated ranges. The
|
|
* list must be kept sorted by spec->path */
|
|
struct line_log_data {
|
|
struct line_log_data *next;
|
|
struct diff_filespec *spec;
|
|
char status;
|
|
struct range_set ranges;
|
|
int arg_alloc, arg_nr;
|
|
const char **args;
|
|
struct diff_filepair *pair;
|
|
struct diff_ranges diff;
|
|
};
|
|
|
|
extern void line_log_data_init(struct line_log_data *r);
|
|
|
|
extern void line_log_init(struct rev_info *rev, const char *prefix, struct string_list *args);
|
|
|
|
extern int line_log_filter(struct rev_info *rev);
|
|
|
|
extern int line_log_print(struct rev_info *rev, struct commit *commit);
|
|
|
|
#endif /* LINE_LOG_H */
|