Code

git-cat-file.txt: Document --textconv
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 502b301670a13ae146974d8ba4a956c2f6e3dbf3..b4a830f88fa7a7367fab505f707237ef11e67114 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -43,10 +43,6 @@ static char diff_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_NORMAL,       /* FUNCINFO */
 };
 
-static void diff_filespec_load_driver(struct diff_filespec *one);
-static size_t fill_textconv(struct userdiff_driver *driver,
-                           struct diff_filespec *df, char **outbuf);
-
 static int parse_diff_color_slot(const char *var, int ofs)
 {
        if (!strcasecmp(var+ofs, "plain"))
@@ -1629,7 +1625,7 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
                options->b_prefix = b;
 }
 
-static struct userdiff_driver *get_textconv(struct diff_filespec *one)
+struct userdiff_driver *get_textconv(struct diff_filespec *one)
 {
        if (!DIFF_FILE_VALID(one))
                return NULL;
@@ -2600,6 +2596,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
 void diff_setup(struct diff_options *options)
 {
        memset(options, 0, sizeof(*options));
+       memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
 
        options->file = stdout;
 
@@ -3541,8 +3538,7 @@ int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1)
                diff_free_filepair(q->queue[i]);
 
        free(q->queue);
-       q->queue = NULL;
-       q->nr = q->alloc = 0;
+       DIFF_QUEUE_CLEAR(q);
 
        return result;
 }
@@ -3670,8 +3666,7 @@ void diff_flush(struct diff_options *options)
                diff_free_filepair(q->queue[i]);
 free_queue:
        free(q->queue);
-       q->queue = NULL;
-       q->nr = q->alloc = 0;
+       DIFF_QUEUE_CLEAR(q);
        if (options->close_file)
                fclose(options->file);
 
@@ -3693,8 +3688,7 @@ static void diffcore_apply_filter(const char *filter)
        int i;
        struct diff_queue_struct *q = &diff_queued_diff;
        struct diff_queue_struct outq;
-       outq.queue = NULL;
-       outq.nr = outq.alloc = 0;
+       DIFF_QUEUE_CLEAR(&outq);
 
        if (!filter)
                return;
@@ -3762,8 +3756,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
        int i;
        struct diff_queue_struct *q = &diff_queued_diff;
        struct diff_queue_struct outq;
-       outq.queue = NULL;
-       outq.nr = outq.alloc = 0;
+       DIFF_QUEUE_CLEAR(&outq);
 
        for (i = 0; i < q->nr; i++) {
                struct diff_filepair *p = q->queue[i];
@@ -3824,6 +3817,12 @@ void diffcore_fix_diff_index(struct diff_options *options)
 
 void diffcore_std(struct diff_options *options)
 {
+       /* We never run this function more than one time, because the
+        * rename/copy detection logic can only run once.
+        */
+       if (diff_queued_diff.run)
+               return;
+
        if (options->skip_stat_unmatch)
                diffcore_skip_stat_unmatch(options);
        if (options->break_opt != -1)
@@ -3843,6 +3842,8 @@ void diffcore_std(struct diff_options *options)
                DIFF_OPT_SET(options, HAS_CHANGES);
        else
                DIFF_OPT_CLR(options, HAS_CHANGES);
+
+       diff_queued_diff.run = 1;
 }
 
 int diff_result_code(struct diff_options *opt, int status)
@@ -3997,9 +3998,9 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        return strbuf_detach(&buf, outsize);
 }
 
-static size_t fill_textconv(struct userdiff_driver *driver,
-                           struct diff_filespec *df,
-                           char **outbuf)
+size_t fill_textconv(struct userdiff_driver *driver,
+                    struct diff_filespec *df,
+                    char **outbuf)
 {
        size_t size;