[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] (but not for gnulib) squash git diff spurious exit code 1
From: |
Thien-Thi Nguyen |
Subject: |
Re: [patch] (but not for gnulib) squash git diff spurious exit code 1 |
Date: |
Thu, 27 Dec 2007 23:34:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
below is an updated patch. it skips all output,
instead of just the stats, for this special case.
thi
_____________________________________________________________________
* diff.c (CHANGE_MIND_LAST_MOMENT_MAYBE): New macro.
(show_stats): Use it immediately prior to output.
(show_shortstats): Likewise. Also, take 2nd arg OPTIONS.
(diff_flush): Update calls to `show_stats' and `show_shortstats'.
Also, if we changed our mind, skip all further output.
--- diff.c.ORIG 2007-10-31 21:04:37.000000000 +0100
+++ diff.c 2007-12-27 23:27:52.000000000 +0100
@@ -823,6 +823,16 @@
printf("%s", reset);
}
+/* If due to these supposedly output-only (sneer) wranglings
+ we have determined there are actually no changes, backpatch
+ the overall status and avoid any output. Blech. --ttn */
+#define CHANGE_MIND_LAST_MOMENT_MAYBE() do { \
+ if (! total_files) { \
+ options->has_changes = 0; \
+ return; \
+ } \
+ } while (0) \
+
static void show_stats(struct diffstat_t* data, struct diff_options *options)
{
int i, len, add, del, total, adds = 0, dels = 0;
@@ -957,11 +967,12 @@
free(data->files[i]);
}
free(data->files);
+ CHANGE_MIND_LAST_MOMENT_MAYBE ();
printf("%s %d files changed, %d insertions(+), %d deletions(-)%s\n",
set, total_files, adds, dels, reset);
}
-static void show_shortstats(struct diffstat_t* data)
+static void show_shortstats(struct diffstat_t* data, struct diff_options
*options)
{
int i, adds = 0, dels = 0, total_files = data->nr;
@@ -985,7 +996,7 @@
free(data->files[i]);
}
free(data->files);
-
+ CHANGE_MIND_LAST_MOMENT_MAYBE ();
printf(" %d files changed, %d insertions(+), %d deletions(-)\n",
total_files, adds, dels);
}
@@ -3055,7 +3066,10 @@
if (output_format & DIFF_FORMAT_DIFFSTAT)
show_stats(&diffstat, options);
else if (output_format & DIFF_FORMAT_SHORTSTAT)
- show_shortstats(&diffstat);
+ show_shortstats(&diffstat, options);
+ /* If we changed our minds, avoid further output totally. */
+ if (! options->has_changes)
+ goto free_filepairs;
separator++;
}
@@ -3085,6 +3099,7 @@
if (output_format & DIFF_FORMAT_CALLBACK)
options->format_callback(q, options,
options->format_callback_data);
+free_filepairs:
for (i = 0; i < q->nr; i++)
diff_free_filepair(q->queue[i]);
free_queue: