summaryrefslogtreecommitdiffstats
path: root/builtin/merge-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/merge-file.c')
-rw-r--r--builtin/merge-file.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index e695867ee5..793817f3cb 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -25,10 +25,10 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
int cmd_merge_file(int argc, const char **argv, const char *prefix)
{
- const char *names[3] = { NULL, NULL, NULL };
- mmfile_t mmfs[3];
- mmbuffer_t result = {NULL, 0};
- xmparam_t xmp = {{0}};
+ const char *names[3] = { 0 };
+ mmfile_t mmfs[3] = { 0 };
+ mmbuffer_t result = { 0 };
+ xmparam_t xmp = { 0 };
int ret = 0, i = 0, to_stdout = 0;
int quiet = 0;
struct option options[] = {
@@ -71,21 +71,23 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
for (i = 0; i < 3; i++) {
char *fname;
- int ret;
+ mmfile_t *mmf = mmfs + i;
if (!names[i])
names[i] = argv[i];
fname = prefix_filename(prefix, argv[i]);
- ret = read_mmfile(mmfs + i, fname);
+
+ if (read_mmfile(mmf, fname))
+ ret = -1;
+ else if (mmf->size > MAX_XDIFF_SIZE ||
+ buffer_is_binary(mmf->ptr, mmf->size))
+ ret = error("Cannot merge binary files: %s",
+ argv[i]);
+
free(fname);
if (ret)
- return -1;
-
- if (mmfs[i].size > MAX_XDIFF_SIZE ||
- buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
- return error("Cannot merge binary files: %s",
- argv[i]);
+ return ret;
}
xmp.ancestor = names[1];