]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Merge branch 'ab/detox-gettext-tests'
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 2253ec880298b4f146cb20f6dbae365d77b8fdfe..bf2cbf15e776d0405aeaf94828e7d64990889f7d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4593,6 +4593,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)
 
        options->orderfile = diff_order_file_cfg;
 
+       if (!options->flags.ignore_submodule_set)
+               options->flags.ignore_untracked_in_submodules = 1;
+
        if (diff_no_prefix) {
                options->a_prefix = options->b_prefix = "";
        } else if (!diff_mnemonic_prefix) {
@@ -6333,6 +6336,32 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o)
        }
 }
 
+static void diff_free_file(struct diff_options *options)
+{
+       if (options->close_file)
+               fclose(options->file);
+}
+
+static void diff_free_ignore_regex(struct diff_options *options)
+{
+       int i;
+
+       for (i = 0; i < options->ignore_regex_nr; i++) {
+               regfree(options->ignore_regex[i]);
+               free(options->ignore_regex[i]);
+       }
+       free(options->ignore_regex);
+}
+
+void diff_free(struct diff_options *options)
+{
+       if (options->no_free)
+               return;
+
+       diff_free_file(options);
+       diff_free_ignore_regex(options);
+}
+
 void diff_flush(struct diff_options *options)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
@@ -6396,8 +6425,7 @@ void diff_flush(struct diff_options *options)
                 * options->file to /dev/null should be safe, because we
                 * aren't supposed to produce any output anyway.
                 */
-               if (options->close_file)
-                       fclose(options->file);
+               diff_free_file(options);
                options->file = xfopen("/dev/null", "w");
                options->close_file = 1;
                options->color_moved = 0;
@@ -6430,8 +6458,7 @@ void diff_flush(struct diff_options *options)
 free_queue:
        free(q->queue);
        DIFF_QUEUE_CLEAR(q);
-       if (options->close_file)
-               fclose(options->file);
+       diff_free(options);
 
        /*
         * Report the content-level differences with HAS_CHANGES;