summaryrefslogtreecommitdiff
path: root/src/diff_parse.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-03-14 11:01:19 +0100
committerPatrick Steinhardt <ps@pks.im>2017-03-14 13:09:35 +0100
commitc0eba379d18c6f7979d09c672b48feeaca69dfbd (patch)
tree120d2d4f442758cdff41dbe9ca7d6ba00125db58 /src/diff_parse.c
parentad5a909cfbb07541e3e2548313043cc3f3a0918a (diff)
downloadlibgit2-c0eba379d18c6f7979d09c672b48feeaca69dfbd.tar.gz
diff_parse: correctly set options for parsed diffs
The function `diff_parsed_alloc` allocates and initializes a `git_diff_parsed` structure. This structure also contains diff options. While we initialize its flags, we fail to do a real initialization of its values. This bites us when we want to actually use the generated diff as we do not se the option's version field, which is required to operate correctly. Fix the issue by executing `git_diff_init_options` on the embedded struct.
Diffstat (limited to 'src/diff_parse.c')
-rw-r--r--src/diff_parse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/diff_parse.c b/src/diff_parse.c
index e640063af..93915683e 100644
--- a/src/diff_parse.c
+++ b/src/diff_parse.c
@@ -37,7 +37,6 @@ static git_diff_parsed *diff_parsed_alloc(void)
GIT_REFCOUNT_INC(diff);
diff->base.type = GIT_DIFF_TYPE_PARSED;
- diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
diff->base.strcomp = git__strcmp;
diff->base.strncomp = git__strncmp;
diff->base.pfxcomp = git__prefixcmp;
@@ -45,6 +44,9 @@ static git_diff_parsed *diff_parsed_alloc(void)
diff->base.patch_fn = git_patch_parsed_from_diff;
diff->base.free_fn = diff_parsed_free;
+ git_diff_init_options(&diff->base.opts, GIT_DIFF_OPTIONS_VERSION);
+ diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
+
git_pool_init(&diff->base.pool, 1);
if (git_vector_init(&diff->patches, 0, NULL) < 0 ||