summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2012-03-14 18:24:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-03-14 21:41:20 (GMT)
commit6440d3417c1d51a20014d4b6fc6c59bacfa87dab (patch)
tree9f8622f346cea445bf7a2840980c3a82f761dd06 /diff.c
parent77d1a520fb5b8ad8cc86228023f16a44b75c05d1 (diff)
downloadgit-6440d3417c1d51a20014d4b6fc6c59bacfa87dab.zip
git-6440d3417c1d51a20014d4b6fc6c59bacfa87dab.tar.gz
git-6440d3417c1d51a20014d4b6fc6c59bacfa87dab.tar.bz2
diff: tweak a _copy_ of diff_options with word-diff
When using word diff, the code sets the word_regex from various defaults if it was not set already. The problem is that it does this on the original diff_options, which will also be used in subsequent diffs. This means that when the word_regex is not given on the command line, only the first diff for which a setting for word_regex (either from attributes or diff.wordRegex) ever takes effect. This value then propagates to the rest of the diff runs and in particular prevents further attribute lookups. Fix the problem of changing diff state once and for all, by working with a _copy_ of the diff_options. Noticed-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 526f198..349a61d 100644
--- a/diff.c
+++ b/diff.c
@@ -1008,11 +1008,13 @@ static const char *userdiff_word_regex(struct diff_filespec *one)
}
static void init_diff_words_data(struct emit_callback *ecbdata,
- struct diff_options *o,
+ struct diff_options *orig_opts,
struct diff_filespec *one,
struct diff_filespec *two)
{
int i;
+ struct diff_options *o = xmalloc(sizeof(struct diff_options));
+ memcpy(o, orig_opts, sizeof(struct diff_options));
ecbdata->diff_words =
xcalloc(1, sizeof(struct diff_words_data));
@@ -1052,6 +1054,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
{
if (ecbdata->diff_words) {
diff_words_flush(ecbdata);
+ free (ecbdata->diff_words->opt);
free (ecbdata->diff_words->minus.text.ptr);
free (ecbdata->diff_words->minus.orig);
free (ecbdata->diff_words->plus.text.ptr);