From: Junio C Hamano Date: Fri, 9 Apr 2010 06:31:27 +0000 (-0700) Subject: Merge early parts of jk/cached-textconv X-Git-Tag: v1.7.1-rc1~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7ec1eb93f779d06efac106cd1998410932f3c9b2?ds=inline;hp=-c Merge early parts of jk/cached-textconv --- 7ec1eb93f779d06efac106cd1998410932f3c9b2 diff --combined diff.c index 167e6a4abd,c23093d6c0..a1bf1e9cb3 --- a/diff.c +++ b/diff.c @@@ -14,7 -14,6 +14,7 @@@ #include "userdiff.h" #include "sigchain.h" #include "submodule.h" +#include "ll-merge.h" #ifdef NO_FAST_WORKING_DIRECTORY #define FAST_WORKING_DIRECTORY 0 @@@ -551,6 -550,10 +551,10 @@@ static void emit_rewrite_diff(const cha emit_rewrite_lines(&ecbdata, '-', data_one, size_one); if (lc_b) emit_rewrite_lines(&ecbdata, '+', data_two, size_two); + if (textconv_one) + free((char *)data_one); + if (textconv_two) + free((char *)data_two); } struct diff_words_buffer { @@@ -1371,32 -1374,37 +1375,32 @@@ static void free_diffstat_info(struct d struct checkdiff_t { const char *filename; int lineno; + int conflict_marker_size; struct diff_options *o; unsigned ws_rule; unsigned status; }; -static int is_conflict_marker(const char *line, unsigned long len) +static int is_conflict_marker(const char *line, int marker_size, unsigned long len) { char firstchar; int cnt; - if (len < 8) + if (len < marker_size + 1) return 0; firstchar = line[0]; switch (firstchar) { - case '=': case '>': case '<': + case '=': case '>': case '<': case '|': break; default: return 0; } - for (cnt = 1; cnt < 7; cnt++) + for (cnt = 1; cnt < marker_size; cnt++) if (line[cnt] != firstchar) return 0; - /* line[0] thru line[6] are same as firstchar */ - if (firstchar == '=') { - /* divider between ours and theirs? */ - if (len != 8 || line[7] != '\n') - return 0; - } else if (len < 8 || !isspace(line[7])) { - /* not divider before ours nor after theirs */ + /* line[1] thru line[marker_size-1] are same as firstchar */ + if (len < marker_size + 1 || !isspace(line[marker_size])) return 0; - } return 1; } @@@ -1404,7 -1412,6 +1408,7 @@@ static void checkdiff_consume(void *pri { struct checkdiff_t *data = priv; int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF); + int marker_size = data->conflict_marker_size; const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE); const char *reset = diff_get_color(color_diff, DIFF_RESET); const char *set = diff_get_color(color_diff, DIFF_FILE_NEW); @@@ -1413,7 -1420,7 +1417,7 @@@ if (line[0] == '+') { unsigned bad; data->lineno++; - if (is_conflict_marker(line + 1, len - 1)) { + if (is_conflict_marker(line + 1, marker_size, len - 1)) { data->status |= 1; fprintf(data->o->file, "%s:%d: leftover conflict marker\n", @@@ -1857,7 -1864,6 +1861,7 @@@ static void builtin_checkdiff(const cha data.lineno = 0; data.o = o; data.ws_rule = whitespace_rule(attr_path); + data.conflict_marker_size = ll_merge_marker_size(attr_path); if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) die("unable to read files to diff");