From: Junio C Hamano Date: Mon, 26 Jun 2006 21:28:42 +0000 (-0700) Subject: Merge branch 'js/diff' X-Git-Tag: v1.4.1-rc2~21 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2cc06a0500b4b69e8563f76c42306e36b1f0aabf?ds=inline;hp=-c Merge branch 'js/diff' * js/diff: Teach diff about -b and -w flags --- 2cc06a0500b4b69e8563f76c42306e36b1f0aabf diff --combined diff.c index 834b166064,585be7e50d..f3585469f5 --- a/diff.c +++ b/diff.c @@@ -203,7 -203,7 +203,7 @@@ static void emit_rewrite_diff(const cha static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one) { if (!DIFF_FILE_VALID(one)) { - mf->ptr = ""; /* does not matter */ + mf->ptr = (char *)""; /* does not matter */ mf->size = 0; return 0; } @@@ -395,7 -395,7 +395,7 @@@ static void show_stats(struct diffstat_ } for (i = 0; i < data->nr; i++) { - char *prefix = ""; + const char *prefix = ""; char *name = data->files[i]->name; int added = data->files[i]->added; int deleted = data->files[i]->deleted; @@@ -616,7 -616,7 +616,7 @@@ static void builtin_diff(const char *na const char *lbl[2]; char *a_one, *b_two; const char *set = get_color(o->color_diff, DIFF_METAINFO); - const char *reset = get_color(o->color_diff, DIFF_PLAIN); + const char *reset = get_color(o->color_diff, DIFF_RESET); a_one = quote_two("a/", name_a); b_two = quote_two("b/", name_b); @@@ -678,7 -678,7 +678,7 @@@ memset(&ecbdata, 0, sizeof(ecbdata)); ecbdata.label_path = lbl; ecbdata.color_diff = o->color_diff; - xpp.flags = XDF_NEED_MINIMAL; + xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = o->context; xecfg.flags = XDL_EMIT_FUNCNAMES; if (!diffopts) @@@ -703,6 -703,7 +703,7 @@@ static void builtin_diffstat(const cha struct diff_filespec *one, struct diff_filespec *two, struct diffstat_t *diffstat, + struct diff_options *o, int complete_rewrite) { mmfile_t mf1, mf2; @@@ -732,7 -733,7 +733,7 @@@ xdemitconf_t xecfg; xdemitcb_t ecb; - xpp.flags = XDF_NEED_MINIMAL; + xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = 0; xecfg.flags = 0; ecb.outf = xdiff_outf; @@@ -917,7 -918,7 +918,7 @@@ int diff_populate_filespec(struct diff_ err_empty: err = -1; empty: - s->data = ""; + s->data = (char *)""; s->size = 0; return err; } @@@ -1317,7 -1318,7 +1318,7 @@@ static void run_diffstat(struct diff_fi if (DIFF_PAIR_UNMERGED(p)) { /* unmerged */ - builtin_diffstat(p->one->path, NULL, NULL, NULL, diffstat, 0); + builtin_diffstat(p->one->path, NULL, NULL, NULL, diffstat, o, 0); return; } @@@ -1329,7 -1330,7 +1330,7 @@@ if (p->status == DIFF_STATUS_MODIFIED && p->score) complete_rewrite = 1; - builtin_diffstat(name, other, p->one, p->two, diffstat, complete_rewrite); + builtin_diffstat(name, other, p->one, p->two, diffstat, o, complete_rewrite); } static void run_checkdiff(struct diff_filepair *p, struct diff_options *o) @@@ -1408,7 -1409,7 +1409,7 @@@ int diff_setup_done(struct diff_option return 0; } -int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val) +static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val) { char c, *eq; int len; @@@ -1534,6 -1535,10 +1535,10 @@@ int diff_opt_parse(struct diff_options } else if (!strcmp(arg, "--color")) options->color_diff = 1; + else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) + options->xdl_opts |= XDF_IGNORE_WHITESPACE; + else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change")) + options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE; else return 0; return 1; @@@ -1720,12 -1725,16 +1725,12 @@@ static void diff_flush_raw(struct diff_ free((void*)path_two); } -static void diff_flush_name(struct diff_filepair *p, - int inter_name_termination, - int line_termination) +static void diff_flush_name(struct diff_filepair *p, int line_termination) { char *path = p->two->path; if (line_termination) path = quote_one(p->two->path); - else - path = p->two->path; printf("%s%c", path, line_termination); if (p->two->path != path) free(path); @@@ -1946,7 -1955,9 +1951,7 @@@ static void flush_one_pair(struct diff_ options, diff_output_format); break; case DIFF_FORMAT_NAME: - diff_flush_name(p, - inter_name_termination, - line_termination); + diff_flush_name(p, line_termination); break; case DIFF_FORMAT_NO_OUTPUT: break;