t4201: make use of abbreviation in the test more robust
[gitweb.git] / builtin / rerere.c
index 12535c9b4f48cd196943c1914fefee7c47cecec2..1bf72423bf72d7b7d224c14808b0652d78305d63 100644 (file)
@@ -29,9 +29,10 @@ static int diff_two(const char *file1, const char *label1,
        xdemitconf_t xecfg;
        xdemitcb_t ecb;
        mmfile_t minus, plus;
+       int ret;
 
        if (read_mmfile(&minus, file1) || read_mmfile(&plus, file2))
-               return 1;
+               return -1;
 
        printf("--- a/%s\n+++ b/%s\n", label1, label2);
        fflush(stdout);
@@ -40,11 +41,11 @@ static int diff_two(const char *file1, const char *label1,
        memset(&xecfg, 0, sizeof(xecfg));
        xecfg.ctxlen = 3;
        ecb.outf = outf;
-       xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
+       ret = xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
 
        free(minus.ptr);
        free(plus.ptr);
-       return 0;
+       return ret;
 }
 
 int cmd_rerere(int argc, const char **argv, const char *prefix)
@@ -103,8 +104,9 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
                        return 0;
                for (i = 0; i < merge_rr.nr; i++) {
                        const char *path = merge_rr.items[i].string;
-                       const char *name = (const char *)merge_rr.items[i].util;
-                       diff_two(rerere_path(name, "preimage"), path, path, path);
+                       const struct rerere_id *id = merge_rr.items[i].util;
+                       if (diff_two(rerere_path(id, "preimage"), path, path, path))
+                               die("unable to generate diff for %s", rerere_path(id, NULL));
                }
        } else
                usage_with_options(rerere_usage, options);