struct sline *lost_bucket;
};
-static void consume_line(void *state_, char *line, unsigned long len)
+static void consume_hunk(void *state_,
+ long ob, long on,
+ long nb, long nn,
+ const char *funcline, long funclen)
{
struct combine_diff_state *state = state_;
- if (5 < len && !memcmp("@@ -", line, 4)) {
- if (parse_hunk_header(line, len,
- &state->ob, &state->on,
- &state->nb, &state->nn))
- return;
- state->lno = state->nb;
- if (state->nn == 0) {
- /* @@ -X,Y +N,0 @@ removed Y lines
- * that would have come *after* line N
- * in the result. Our lost buckets hang
- * to the line after the removed lines,
- *
- * Note that this is correct even when N == 0,
- * in which case the hunk removes the first
- * line in the file.
- */
- state->lost_bucket = &state->sline[state->nb];
- if (!state->nb)
- state->nb = 1;
- } else {
- state->lost_bucket = &state->sline[state->nb-1];
- }
- if (!state->sline[state->nb-1].p_lno)
- state->sline[state->nb-1].p_lno =
- xcalloc(state->num_parent,
- sizeof(unsigned long));
- state->sline[state->nb-1].p_lno[state->n] = state->ob;
- return;
+
+ state->ob = ob;
+ state->on = on;
+ state->nb = nb;
+ state->nn = nn;
+ state->lno = state->nb;
+ if (state->nn == 0) {
+ /* @@ -X,Y +N,0 @@ removed Y lines
+ * that would have come *after* line N
+ * in the result. Our lost buckets hang
+ * to the line after the removed lines,
+ *
+ * Note that this is correct even when N == 0,
+ * in which case the hunk removes the first
+ * line in the file.
+ */
+ state->lost_bucket = &state->sline[state->nb];
+ if (!state->nb)
+ state->nb = 1;
+ } else {
+ state->lost_bucket = &state->sline[state->nb-1];
}
+ if (!state->sline[state->nb-1].p_lno)
+ state->sline[state->nb-1].p_lno =
+ xcalloc(state->num_parent, sizeof(unsigned long));
+ state->sline[state->nb-1].p_lno[state->n] = state->ob;
+}
+
+static void consume_line(void *state_, char *line, unsigned long len)
+{
+ struct combine_diff_state *state = state_;
if (!state->lost_bucket)
return; /* not in any hunk yet */
switch (line[0]) {
state.num_parent = num_parent;
state.n = n;
- if (xdi_diff_outf(&parent_file, result_file, consume_line, &state,
- &xpp, &xecfg))
+ if (xdi_diff_outf(&parent_file, result_file, consume_hunk,
+ consume_line, &state, &xpp, &xecfg))
die("unable to generate combined diff for %s",
oid_to_hex(parent));
free(parent_file.ptr);
if (!userdiff)
userdiff = userdiff_find_by_name("default");
if (opt->flags.allow_textconv)
- textconv = userdiff_get_textconv(userdiff);
+ textconv = userdiff_get_textconv(opt->repo, userdiff);
/* Read the result of merge first */
if (!working_tree_file)