bug-gnulib
[Top][All Lists]
Advanced

[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: Jim Meyering
Subject: Re: [patch] (but not for gnulib) squash git diff spurious exit code 1
Date: Fri, 28 Dec 2007 22:41:37 +0100

Thien-Thi Nguyen <address@hidden> wrote:
> () Jim Meyering <address@hidden>
> () Thu, 27 Dec 2007 22:13:53 +0100
>
>    [test case?]
>
> thanks for looking into this.
...
> try      --stat
> try --shortstat

I've adapted your patch to apply to the trunk.
New one below.

It looks like you may want to adjust it further,
so that "git diff-index..." with neither --stat option
also exits successfully.

Do you feel like pursuing it?
---------------

>From 1d6a92c7fa4ba857e7b541fe60ffaf3c00fc282c Mon Sep 17 00:00:00 2001
From: Thien-Thi Nguyen <address@hidden>
Date: Fri, 28 Dec 2007 22:31:03 +0100
Subject: [PATCH] git diff-index: exit 0 when only difference is in mtime

---
 diff.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index 5bdc111..94b9a41 100644
--- a/diff.c
+++ b/diff.c
@@ -769,6 +769,16 @@ static void fill_print_name(struct diffstat_file *file)
        file->print_name = pname;
 }

+/* 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) {                       \
+      DIFF_OPT_CLR(options, HAS_CHANGES);      \
+      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;
@@ -889,11 +899,13 @@ static void show_stats(struct diffstat_t* data, struct 
diff_options *options)
                show_graph('-', del, del_c, reset);
                putchar('\n');
        }
+       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;

@@ -914,6 +926,7 @@ static void show_shortstats(struct diffstat_t* data)
                        }
                }
        }
+       CHANGE_MIND_LAST_MOMENT ();
        printf(" %d files changed, %d insertions(+), %d deletions(-)\n",
               total_files, adds, dels);
 }
@@ -2911,7 +2924,7 @@ void diff_flush(struct diff_options *options)
                if (output_format & DIFF_FORMAT_DIFFSTAT)
                        show_stats(&diffstat, options);
                if (output_format & DIFF_FORMAT_SHORTSTAT)
-                       show_shortstats(&diffstat);
+                       show_shortstats(&diffstat, options);
                free_diffstat_info(&diffstat);
                separator++;
        }
-- 
1.5.4.rc2.1.gc00e




reply via email to

[Prev in Thread] Current Thread [Next in Thread]