[PATCH] Make the test more shell generic and fix missing Solaris find option
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 77d3166..9bded28 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -674,11 +674,12 @@ void diff_setup(struct diff_options *options)
        options->output_format = DIFF_FORMAT_RAW;
        options->line_termination = '\n';
        options->break_opt = -1;
+       options->rename_limit = -1;
 }
 
 int diff_setup_done(struct diff_options *options)
 {
-       if (options->find_copies_harder &&
+       if ((options->find_copies_harder || 0 <= options->rename_limit) &&
            options->detect_rename != DIFF_DETECT_COPY)
                return -1;
        if (options->setup & DIFF_SETUP_USE_CACHE) {
@@ -704,8 +705,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                options->output_format = DIFF_FORMAT_PATCH;
        else if (!strcmp(arg, "-z"))
                options->line_termination = 0;
+       else if (!strncmp(arg, "-l", 2))
+               options->rename_limit = strtoul(arg+2, NULL, 10);
        else if (!strcmp(arg, "--name-only"))
                options->output_format = DIFF_FORMAT_NAME;
+       else if (!strcmp(arg, "--name-status"))
+               options->output_format = DIFF_FORMAT_NAME_STATUS;
        else if (!strcmp(arg, "-R"))
                options->reverse_diff = 1;
        else if (!strncmp(arg, "-S", 2))
@@ -832,7 +837,8 @@ void diff_free_filepair(struct diff_filepair *p)
 
 static void diff_flush_raw(struct diff_filepair *p,
                           int line_termination,
-                          int inter_name_termination)
+                          int inter_name_termination,
+                          int output_format)
 {
        int two_paths;
        char status[10];
@@ -868,13 +874,12 @@ static void diff_flush_raw(struct diff_filepair *p,
                two_paths = 0;
                break;
        }
-       printf(":%06o %06o %s ",
-              p->one->mode, p->two->mode, sha1_to_hex(p->one->sha1));
-       printf("%s %s%c%s",
-              sha1_to_hex(p->two->sha1),
-              status,
-              inter_name_termination,
-              p->one->path);
+       if (output_format != DIFF_FORMAT_NAME_STATUS) {
+               printf(":%06o %06o %s ",
+                      p->one->mode, p->two->mode, sha1_to_hex(p->one->sha1));
+               printf("%s ", sha1_to_hex(p->two->sha1));
+       }
+       printf("%s%c%s",status, inter_name_termination, p->one->path);
        if (two_paths)
                printf("%c%s", inter_name_termination, p->two->path);
        putchar(line_termination);
@@ -1064,8 +1069,10 @@ void diff_flush(struct diff_options *options)
                        diff_flush_patch(p);
                        break;
                case DIFF_FORMAT_RAW:
+               case DIFF_FORMAT_NAME_STATUS:
                        diff_flush_raw(p, line_termination,
-                                      inter_name_termination);
+                                      inter_name_termination,
+                                      diff_output_format);
                        break;
                case DIFF_FORMAT_NAME:
                        diff_flush_name(p, line_termination);
@@ -1141,7 +1148,7 @@ void diffcore_std(struct diff_options *options)
        if (options->break_opt != -1)
                diffcore_break(options->break_opt);
        if (options->detect_rename)
-               diffcore_rename(options->detect_rename, options->rename_score);
+               diffcore_rename(options);
        if (options->break_opt != -1)
                diffcore_merge_broken();
        if (options->pickaxe)