From: Junio C Hamano Date: Tue, 2 Mar 2010 20:44:10 +0000 (-0800) Subject: Merge branch 'ld/maint-diff-quiet-w' X-Git-Tag: v1.7.1-rc0~110 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/36420805a738d1cf17e7faf54556b35344421515?ds=inline;hp=-c Merge branch 'ld/maint-diff-quiet-w' * ld/maint-diff-quiet-w: git-diff: add a test for git diff --quiet -w git diff --quiet -w: check and report the status --- 36420805a738d1cf17e7faf54556b35344421515 diff --combined diff.c index ed3e7c5aaf,7216b1e8db..dfdfa1a813 --- a/diff.c +++ b/diff.c @@@ -2826,15 -2826,6 +2826,15 @@@ int diff_opt_parse(struct diff_options DIFF_OPT_SET(options, FOLLOW_RENAMES); else if (!strcmp(arg, "--color")) DIFF_OPT_SET(options, COLOR_DIFF); + else if (!prefixcmp(arg, "--color=")) { + int value = git_config_colorbool(NULL, arg+8, -1); + if (value == 0) + DIFF_OPT_CLR(options, COLOR_DIFF); + else if (value > 0) + DIFF_OPT_SET(options, COLOR_DIFF); + else + return error("option `color' expects \"always\", \"auto\", or \"never\""); + } else if (!strcmp(arg, "--no-color")) DIFF_OPT_CLR(options, COLOR_DIFF); else if (!strcmp(arg, "--color-words")) { @@@ -2902,8 -2893,6 +2902,8 @@@ ; else if (!prefixcmp(arg, "--output=")) { options->file = fopen(arg + strlen("--output="), "w"); + if (!options->file) + die_errno("Could not open '%s'", arg + strlen("--output=")); options->close_file = 1; } else return 0; @@@ -3531,6 -3520,29 +3531,29 @@@ void diff_flush(struct diff_options *op separator++; } + if (output_format & DIFF_FORMAT_NO_OUTPUT && + DIFF_OPT_TST(options, EXIT_WITH_STATUS) && + DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) { + /* + * run diff_flush_patch for the exit status. setting + * options->file to /dev/null should be safe, becaue we + * aren't supposed to produce any output anyway. + */ + if (options->close_file) + fclose(options->file); + options->file = fopen("/dev/null", "w"); + if (!options->file) + die_errno("Could not open /dev/null"); + options->close_file = 1; + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (check_pair_status(p)) + diff_flush_patch(p, options); + if (options->found_changes) + break; + } + } + if (output_format & DIFF_FORMAT_PATCH) { if (separator) { putc(options->line_termination, options->file); @@@ -3653,7 -3665,7 +3676,7 @@@ static void diffcore_skip_stat_unmatch( struct diff_filepair *p = q->queue[i]; /* - * 1. Entries that come from stat info dirtyness + * 1. Entries that come from stat info dirtiness * always have both sides (iow, not create/delete), * one side of the object name is unknown, with * the same mode and size. Keep the ones that