]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Merge branch 'ss/describe-dirty-in-the-right-directory'
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 084bf542931e09c03a7627740f9177e5c9fac5d9..5306c48652db59e84c26383d68cf4a7d896647d4 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3544,7 +3544,7 @@ static void builtin_diff(const char *name_a,
                o->found_changes = 1;
        } else {
                /* Crazy xdl interfaces.. */
-               const char *diffopts = getenv("GIT_DIFF_OPTS");
+               const char *diffopts;
                const char *v;
                xpparam_t xpp;
                xdemitconf_t xecfg;
@@ -3587,12 +3587,15 @@ static void builtin_diff(const char *name_a,
                        xecfg.flags |= XDL_EMIT_FUNCCONTEXT;
                if (pe)
                        xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
+
+               diffopts = getenv("GIT_DIFF_OPTS");
                if (!diffopts)
                        ;
                else if (skip_prefix(diffopts, "--unified=", &v))
                        xecfg.ctxlen = strtoul(v, NULL, 10);
                else if (skip_prefix(diffopts, "-u", &v))
                        xecfg.ctxlen = strtoul(v, NULL, 10);
+
                if (o->word_diff)
                        init_diff_words_data(&ecbdata, o, one, two);
                if (xdi_diff_outf(&mf1, &mf2, NULL, fn_out_consume,
@@ -5959,8 +5962,10 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o)
 
                for (i = 0; i < esm.nr; i++)
                        free((void *)esm.buf[i].line);
+               esm.nr = 0;
+
+               o->emitted_symbols = NULL;
        }
-       esm.nr = 0;
 }
 
 void diff_flush(struct diff_options *options)