+static char *diff_cmd = "diff -L 'a/%s' -L 'b/%s' ";
+static char *diff_opts = "-p -u";
+static char *diff_arg_forward = " - '%s'";
+static char *diff_arg_reverse = " '%s' -";
+
+static void prepare_diff_cmd(void)
+{
+ /*
+ * Default values above are meant to match the
+ * Linux kernel development style. Examples of
+ * alternative styles you can specify via environment
+ * variables are:
+ *
+ * GIT_DIFF_CMD="diff -L '%s' -L '%s'"
+ * GIT_DIFF_OPTS="-c";
+ */
+ diff_cmd = getenv("GIT_DIFF_CMD") ? : diff_cmd;
+ diff_opts = getenv("GIT_DIFF_OPTS") ? : diff_opts;
+}
+
+/* Help to copy the thing properly quoted for the shell safety.
+ * any single quote is replaced with '\'', and the caller is
+ * expected to enclose the result within a single quote pair.
+ *
+ * E.g.
+ * original sq_expand result
+ * name ==> name ==> 'name'
+ * a b ==> a b ==> 'a b'
+ * a'b ==> a'\''b ==> 'a'\''b'
+ */
+static char *sq_expand(char *src)
+{
+ static char *buf = NULL;
+ int cnt, c;
+ char *cp;
+
+ /* count bytes needed to store the quoted string. */
+ for (cnt = 1, cp = src; *cp; cnt++, cp++)
+ if (*cp == '\'')
+ cnt += 3;
+
+ if (! (buf = malloc(cnt)))
+ return buf;
+ cp = buf;
+ while ((c = *src++)) {
+ if (c != '\'')
+ *cp++ = c;
+ else {
+ cp = strcpy(cp, "'\\''");
+ cp += 4;
+ }
+ }
+ *cp = 0;
+ return buf;
+}
+
+static void show_differences(char *name, char *label, void *old_contents,
+ unsigned long long old_size, int reverse)