Fix tests with new git in C
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 823c8d0..fca61f3 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -13,6 +13,8 @@ static const char *diff_opts = "-pu";
 
 static int use_size_cache;
 
+int diff_rename_limit_default = -1;
+
 static char *quote_one(const char *str)
 {
        int needlen;
@@ -174,7 +176,7 @@ static void builtin_diff(const char *name_a,
 {
        int i, next_at, cmd_size;
        const char *const diff_cmd = "diff -L%s -L%s";
-       const char *const diff_arg  = "%s %s||:"; /* "||:" is to return 0 */
+       const char *const diff_arg  = "-- %s %s||:"; /* "||:" is to return 0 */
        const char *input_name_sq[2];
        const char *label_path[2];
        char *cmd;
@@ -754,13 +756,19 @@ void diff_setup(struct diff_options *options)
        options->line_termination = '\n';
        options->break_opt = -1;
        options->rename_limit = -1;
+
+       options->change = diff_change;
+       options->add_remove = diff_addremove;
 }
 
 int diff_setup_done(struct diff_options *options)
 {
-       if ((options->find_copies_harder || 0 <= options->rename_limit) &&
-           options->detect_rename != DIFF_DETECT_COPY)
+       if ((options->find_copies_harder &&
+            options->detect_rename != DIFF_DETECT_COPY) ||
+           (0 <= options->rename_limit && !options->detect_rename))
                return -1;
+       if (options->detect_rename && options->rename_limit < 0)
+               options->rename_limit = diff_rename_limit_default;
        if (options->setup & DIFF_SETUP_USE_CACHE) {
                if (!active_cache)
                        /* read-cache does not die even when it fails