Which merge_file() function do you mean?

There are two different static functions and one global function, all of them called "merge_file()", with different signatures and purposes. Rename them all to reduce confusion in "git grep" output: * Rename the static one in merge-index to "merge_one_path(const char *path)" as that function is about asking an external command to resolve conflicts in one path. * Rename the global one in merge-file.c that is only used by merge-tree to "merge_blobs()", as the function takes three blobs and returns the merged result only in-core, without doing anything to the filesystem. * Rename the one in merge-recursive to "merge_one_file()", just to be fair. Also rename merge-file.[ch] to merge-blobs.[ch]. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 6, 2012 at 15:08 UTC fa2364ec3457cc107e47d617779f1ffa23647ca4
7 files changed +18 -17
Makefile
+1 -1
@@ -765,7 +765,7 @@ LIB_OBJS += log-tree.o
765 LIB_OBJS += mailmap.o
766 LIB_OBJS += match-trees.o
767 LIB_OBJS += merge.o
768 -LIB_OBJS += merge-file.o
768 +LIB_OBJS += merge-blobs.o
769 LIB_OBJS += merge-recursive.o
770 LIB_OBJS += mergesort.o
771 LIB_OBJS += name-hash.o
builtin/merge-index.c
+2 -2
@@ -42,7 +42,7 @@ static int merge_entry(int pos, const char *path)
42 return found;
43 }
44
45 -static void merge_file(const char *path)
45 +static void merge_one_path(const char *path)
46 {
47 int pos = cache_name_pos(path, strlen(path));
48
@@ -102,7 +102,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
102 }
103 die("git merge-index: unknown option %s", arg);
104 }
105 - merge_file(arg);
105 + merge_one_path(arg);
106 }
107 if (err && !quiet)
108 die("merge program failed");
builtin/merge-tree.c
+2 -2
@@ -3,7 +3,7 @@
3 #include "xdiff-interface.h"
4 #include "blob.h"
5 #include "exec_cmd.h"
6 -#include "merge-file.h"
6 +#include "merge-blobs.h"
7
8 static const char merge_tree_usage[] = "git merge-tree <base-tree> <branch1> <branch2>";
9 static int resolve_directories = 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_file(path, base, our, their, size);
79 + return merge_blobs(path, base, our, their, size);
80 }
81
82 static void *origin(struct merge_list *entry, unsigned long *size)
merge-blobs.c renamed
+2 -2
@@ -3,7 +3,7 @@
3 #include "xdiff-interface.h"
4 #include "ll-merge.h"
5 #include "blob.h"
6 -#include "merge-file.h"
6 +#include "merge-blobs.h"
7
8 static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
9 {
@@ -80,7 +80,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
80 return xdi_diff(f1, f2, &xpp, &xecfg, &ecb);
81 }
82
83 -void *merge_file(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
83 +void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
84 {
85 void *res = NULL;
86 mmfile_t f1, f2, common;
merge-blobs.h new
+8
@@ -0,0 +1,8 @@
1 +#ifndef MERGE_BLOBS_H
2 +#define MERGE_BLOBS_H
3 +
4 +#include "blob.h"
5 +
6 +extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, unsigned long *);
7 +
8 +#endif /* MERGE_BLOBS_H */
merge-file.h deleted
-7
@@ -1,7 +0,0 @@
1 -#ifndef MERGE_FILE_H
2 -#define MERGE_FILE_H
3 -
4 -extern void *merge_file(const char *path, struct blob *base, struct blob *our,
5 - struct blob *their, unsigned long *size);
6 -
7 -#endif
merge-recursive.c
+3 -3
@@ -976,7 +976,7 @@ merge_file_special_markers(struct merge_options *o,
976 return mfi;
977 }
978
979 -static struct merge_file_info merge_file(struct merge_options *o,
979 +static struct merge_file_info merge_file_one(struct merge_options *o,
980 const char *path,
981 const unsigned char *o_sha, int o_mode,
982 const unsigned char *a_sha, int a_mode,
@@ -1166,7 +1166,7 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
1166 struct merge_file_info mfi;
1167 struct diff_filespec other;
1168 struct diff_filespec *add;
1169 - mfi = merge_file(o, one->path,
1169 + mfi = merge_file_one(o, one->path,
1170 one->sha1, one->mode,
1171 a->sha1, a->mode,
1172 b->sha1, b->mode,
@@ -1450,7 +1450,7 @@ static int process_renames(struct merge_options *o,
1450 ren1_dst, branch2);
1451 if (o->call_depth) {
1452 struct merge_file_info mfi;
1453 - mfi = merge_file(o, ren1_dst, null_sha1, 0,
1453 + mfi = merge_file_one(o, ren1_dst, null_sha1, 0,
1454 ren1->pair->two->sha1, ren1->pair->two->mode,
1455 dst_other.sha1, dst_other.mode,
1456 branch1, branch2);