first off, apologies to anyone offended by my sending a patch for git to this mailing list. clearly offtopic. but maybe not completely. please allow this brief explanation: i remember faintly someone talking about "git diff" (and brethren) returning non-zero spuriously even when there were no differences, and just recently i encountered this anomoly myself.
so i set off to fix things. ugh! single-stepping (and thus having to peer) through git-1.5.3.5/diff.c almost made me retch, so you might be able to imagine what relief it was to figure out what kludge was to be snarled from the kludge-kit, before escaping, nose pinched lest the heinous cesspool alter me chemically (more than it did already). simple testing: works fine. so on to the next step, do `diff -u diff.c.ORIG diff.c' (see below) and hunt for the git mailing list address. on the way, i stumble upon a big honking camel-cased file telling me how to avoid MIME so that we can show off how comfortable we are toiling away in the kludge-kit. that's fine. i can `C-x i' like the best of them. however, i got a little miffed reading "Generate your patch using git tools out of your commits" and "Your patch is not judged by who you are", which seem just slightly discordant. hey, what if i am a not-git-diff-using-in-actuality-a-git-diff-fixing kind of person? will my patch be judged negatively? will i need to endure the approbations (gentle or othersise) of the git maintainer(s)? why doesn't the code show the same attention to PROCESS. why isn't the THOUGHT APPLIED? WHO WAS IT THAT INSPIRED ME TO TRY GIT IN THE FIRST PLACE?! then i remembered, it was gnulib denizens. ah, justice! so, in the spirit of sharing around, instead of through, the tree trunk, i post this here in hopes that it will be useful to git users, and that perhaps one of them may muster the patience (more than what i have) to fling the kludge upstream to bake in the flybuzz. ok, so the explanation was not brief. but it felt good! thi _____________________________________________________________ * diff.c (CHANGE_MIND_LAST_MOMENT): New macro. (show_stats): Use it immediately prior to output. (show_shortstats): Likewise. Also, take 2nd arg OPTIONS. Unique caller updated. diff -u git-1.5.3.5/diff.c.ORIG git-1.5.3.5/diff.c --- git-1.5.3.5/diff.c.ORIG 2007-10-31 21:04:37.000000000 +0100 +++ git-1.5.3.5/diff.c 2007-12-27 21:20:13.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() 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 (); 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 (); printf(" %d files changed, %d insertions(+), %d deletions(-)\n", total_files, adds, dels); } @@ -3055,7 +3066,7 @@ if (output_format & DIFF_FORMAT_DIFFSTAT) show_stats(&diffstat, options); else if (output_format & DIFF_FORMAT_SHORTSTAT) - show_shortstats(&diffstat); + show_shortstats(&diffstat, options); separator++; } Diff finished. Thu Dec 27 21:22:31 2007