merge-blobs.c: remove implicit dependency on the_index

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Sep 21, 2018 at 17:57 UTC f4a55b27977aeaddbfb73041be26701bcd3868a5
3 files changed +17 -7
builtin/merge-tree.c
+1 -1
@@ -76,7 +76,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
76 their = NULL;
77 if (entry)
78 their = entry->blob;
79 - return merge_blobs(path, base, our, their, size);
79 + return merge_blobs(&the_index, path, base, our, their, size);
80 }
81
82 static void *origin(struct merge_list *entry, unsigned long *size)
merge-blobs.c
+11 -4
@@ -29,7 +29,12 @@ static void free_mmfile(mmfile_t *f)
29 free(f->ptr);
30 }
31
32 -static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)
32 +static void *three_way_filemerge(struct index_state *istate,
33 + const char *path,
34 + mmfile_t *base,
35 + mmfile_t *our,
36 + mmfile_t *their,
37 + unsigned long *size)
38 {
39 int merge_status;
40 mmbuffer_t res;
@@ -42,7 +47,7 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our
47 */
48 merge_status = ll_merge(&res, path, base, NULL,
49 our, ".our", their, ".their",
45 - &the_index, NULL);
50 + istate, NULL);
51 if (merge_status < 0)
52 return NULL;
53
@@ -50,7 +55,9 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our
55 return res.ptr;
56 }
57
53 -void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
58 +void *merge_blobs(struct index_state *istate, const char *path,
59 + struct blob *base, struct blob *our,
60 + struct blob *their, unsigned long *size)
61 {
62 void *res = NULL;
63 mmfile_t f1, f2, common;
@@ -83,7 +90,7 @@ void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct
90 common.ptr = xstrdup("");
91 common.size = 0;
92 }
86 - res = three_way_filemerge(path, &common, &f1, &f2, size);
93 + res = three_way_filemerge(istate, path, &common, &f1, &f2, size);
94 free_mmfile(&common);
95 out_free_f2_f1:
96 free_mmfile(&f2);
merge-blobs.h
+5 -2
@@ -1,8 +1,11 @@
1 #ifndef MERGE_BLOBS_H
2 #define MERGE_BLOBS_H
3
4 -#include "blob.h"
4 +struct blob;
5 +struct index_state;
6
6 -extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, unsigned long *);
7 +extern void *merge_blobs(struct index_state *, const char *,
8 + struct blob *, struct blob *,
9 + struct blob *, unsigned long *);
10
11 #endif /* MERGE_BLOBS_H */