Skip to content

Commit fa2364e

Browse files
committed
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 <[email protected]>
1 parent fb4c622 commit fa2364e

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ LIB_OBJS += log-tree.o
765765
LIB_OBJS += mailmap.o
766766
LIB_OBJS += match-trees.o
767767
LIB_OBJS += merge.o
768-
LIB_OBJS += merge-file.o
768+
LIB_OBJS += merge-blobs.o
769769
LIB_OBJS += merge-recursive.o
770770
LIB_OBJS += mergesort.o
771771
LIB_OBJS += name-hash.o

builtin/merge-index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int merge_entry(int pos, const char *path)
4242
return found;
4343
}
4444

45-
static void merge_file(const char *path)
45+
static void merge_one_path(const char *path)
4646
{
4747
int pos = cache_name_pos(path, strlen(path));
4848

@@ -102,7 +102,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
102102
}
103103
die("git merge-index: unknown option %s", arg);
104104
}
105-
merge_file(arg);
105+
merge_one_path(arg);
106106
}
107107
if (err && !quiet)
108108
die("merge program failed");

builtin/merge-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "xdiff-interface.h"
44
#include "blob.h"
55
#include "exec_cmd.h"
6-
#include "merge-file.h"
6+
#include "merge-blobs.h"
77

88
static const char merge_tree_usage[] = "git merge-tree <base-tree> <branch1> <branch2>";
99
static int resolve_directories = 1;
@@ -76,7 +76,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
7676
their = NULL;
7777
if (entry)
7878
their = entry->blob;
79-
return merge_file(path, base, our, their, size);
79+
return merge_blobs(path, base, our, their, size);
8080
}
8181

8282
static void *origin(struct merge_list *entry, unsigned long *size)

merge-file.c renamed to merge-blobs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "xdiff-interface.h"
44
#include "ll-merge.h"
55
#include "blob.h"
6-
#include "merge-file.h"
6+
#include "merge-blobs.h"
77

88
static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
99
{
@@ -80,7 +80,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
8080
return xdi_diff(f1, f2, &xpp, &xecfg, &ecb);
8181
}
8282

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)
8484
{
8585
void *res = NULL;
8686
mmfile_t f1, f2, common;

merge-blobs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 7 deletions
This file was deleted.

merge-recursive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ merge_file_special_markers(struct merge_options *o,
976976
return mfi;
977977
}
978978

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,
980980
const char *path,
981981
const unsigned char *o_sha, int o_mode,
982982
const unsigned char *a_sha, int a_mode,
@@ -1166,7 +1166,7 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
11661166
struct merge_file_info mfi;
11671167
struct diff_filespec other;
11681168
struct diff_filespec *add;
1169-
mfi = merge_file(o, one->path,
1169+
mfi = merge_file_one(o, one->path,
11701170
one->sha1, one->mode,
11711171
a->sha1, a->mode,
11721172
b->sha1, b->mode,
@@ -1450,7 +1450,7 @@ static int process_renames(struct merge_options *o,
14501450
ren1_dst, branch2);
14511451
if (o->call_depth) {
14521452
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,
14541454
ren1->pair->two->sha1, ren1->pair->two->mode,
14551455
dst_other.sha1, dst_other.mode,
14561456
branch1, branch2);

0 commit comments

Comments
 (0)