Give commit message reencoding for output on MinGW a chance
[git/dscho.git] / line.h
blobc00f1e60247b9d5e78094308ac757b9c3babc846
1 #ifndef LINE_H
2 #define LINE_H
4 #include "diffcore.h"
6 struct rev_info;
7 struct commit;
8 struct diff_line_range;
9 struct diff_options;
11 typedef const char *(*nth_line_fn_t)(void *data, long lno);
13 struct print_range {
14 int start, end; /* Line range of post-image */
15 int pstart, pend; /* Line range of pre-image */
16 int line_added : 1; /* whether this range is added */
19 struct print_pair {
20 int alloc, nr;
21 struct print_range *ranges;
24 #define PRINT_RANGE_INIT(r) \
25 do { \
26 (r)->start = (r)->end = 0; \
27 (r)->pstart = (r)->pend = 0; \
28 (r)->line_added = 0; \
29 } while (0)
31 #define PRINT_PAIR_INIT(p) \
32 do { \
33 (p)->alloc = (p)->nr = 0; \
34 (p)->ranges = NULL; \
35 } while (0)
37 #define PRINT_PAIR_GROW(p) \
38 do { \
39 (p)->nr++; \
40 ALLOC_GROW((p)->ranges, (p)->nr, (p)->alloc); \
41 } while (0)
43 #define PRINT_PAIR_CLEAR(p) \
44 do { \
45 (p)->alloc = (p)->nr = 0; \
46 if ((p)->ranges) \
47 free((p)->ranges); \
48 (p)->ranges = NULL; \
49 } while (0)
51 struct line_range {
52 const char *arg; /* The argument to specify this line range */
53 long start, end; /* The interesting line range of current commit */
54 long pstart, pend; /* The corresponding range of parent commit */
55 struct print_pair pair;
56 /* The changed lines inside this range */
57 unsigned int diff:1;
60 struct diff_line_range {
61 struct diff_filespec *prev;
62 struct diff_filespec *spec;
63 char status;
64 int alloc;
65 int nr;
66 struct line_range *ranges;
67 unsigned int touch:1,
68 diff:1;
69 struct diff_line_range *next;
72 #define RANGE_INIT(r) \
73 do { \
74 (r)->arg = NULL; \
75 (r)->start = (r)->end = 0; \
76 (r)->pstart = (r)->pend = 0; \
77 PRINT_PAIR_INIT(&((r)->pair)); \
78 (r)->diff = 0; \
79 } while (0)
81 #define RANGE_CLEAR(r) \
82 do { \
83 (r)->arg = NULL; \
84 (r)->start = (r)->end = 0; \
85 (r)->pstart = (r)->pend = 0; \
86 PRINT_PAIR_CLEAR(&r->pair); \
87 (r)->diff = 0; \
88 } while (0)
90 #define DIFF_LINE_RANGE_INIT(r) \
91 do { \
92 (r)->prev = (r)->spec = NULL; \
93 (r)->status = '\0'; \
94 (r)->alloc = (r)->nr = 0; \
95 (r)->ranges = NULL; \
96 (r)->next = NULL; \
97 (r)->touch = 0; \
98 (r)->diff = 0; \
99 } while (0)
101 #define DIFF_LINE_RANGE_GROW(r) \
102 do { \
103 (r)->nr++; \
104 ALLOC_GROW((r)->ranges, (r)->nr, (r)->alloc); \
105 RANGE_INIT(((r)->ranges + (r)->nr - 1)); \
106 } while (0)
108 #define DIFF_LINE_RANGE_CLEAR(r) \
109 diff_line_range_clear((r));
111 extern struct line_range *diff_line_range_insert(struct diff_line_range *r,
112 const char *arg, int start, int end);
114 extern void diff_line_range_append(struct diff_line_range *r, const char *arg);
116 extern void diff_line_range_clear(struct diff_line_range *r);
118 extern struct diff_line_range *diff_line_range_merge(
119 struct diff_line_range *out,
120 struct diff_line_range *other);
122 extern struct diff_line_range *diff_line_range_clone(struct diff_line_range *r);
124 extern struct diff_line_range *diff_line_range_clone_deeply(struct diff_line_range *r);
126 extern void setup_line(struct rev_info *rev, struct diff_line_range *r);
128 extern void add_line_range(struct rev_info *revs, struct commit *commit,
129 struct diff_line_range *r);
131 extern struct diff_line_range *lookup_line_range(struct rev_info *revs,
132 struct commit *commit);
134 const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
135 void *data, long lines, long begin, long *ret);
137 extern int cmd_line_log_walk(struct rev_info *rev);
139 extern void limit_list_line(struct rev_info *rev);
141 #endif