summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa39b6b)
raw | patch | inline | side by side (parent: fa39b6b)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Wed, 20 Dec 2006 16:37:07 +0000 (17:37 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 22 Dec 2006 07:10:14 +0000 (23:10 -0800) |
read_file() was a useful function if you want to work with the xdiff stuff,
so it was renamed and put into a more central place.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
so it was renamed and put into a more central place.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-merge-file.c | patch | blob | history | |
xdiff-interface.c | patch | blob | history | |
xdiff-interface.h | patch | blob | history |
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 6c4c3a351333b94ab62b77793b540af5c9bcaa3a..913577390862a847857a650516740059072b60ad 100644 (file)
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
#include "cache.h"
#include "xdiff/xdiff.h"
+#include "xdiff-interface.h"
static const char merge_file_usage[] =
"git merge-file [-p | --stdout] [-q | --quiet] [-L name1 [-L orig [-L name2]]] file1 orig_file file2";
-static int read_file(mmfile_t *ptr, const char *filename)
-{
- struct stat st;
- FILE *f;
-
- if (stat(filename, &st))
- return error("Could not stat %s", filename);
- if ((f = fopen(filename, "rb")) == NULL)
- return error("Could not open %s", filename);
- ptr->ptr = xmalloc(st.st_size);
- if (fread(ptr->ptr, st.st_size, 1, f) != 1)
- return error("Could not read %s", filename);
- fclose(f);
- ptr->size = st.st_size;
- return 0;
-}
-
int cmd_merge_file(int argc, char **argv, char **envp)
{
char *names[3];
names[i] = argv[i + 1];
for (i = 0; i < 3; i++)
- if (read_file(mmfs + i, argv[i + 1]))
+ if (read_mmfile(mmfs + i, argv[i + 1]))
return -1;
ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 08602f522183dc43787616f37cba9b8af4e3dade..6c1f99b149f0800a9c9ab1b45033bc1401a84766 100644 (file)
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
}
return 0;
}
+
+int read_mmfile(mmfile_t *ptr, const char *filename)
+{
+ struct stat st;
+ FILE *f;
+
+ if (stat(filename, &st))
+ return error("Could not stat %s", filename);
+ if ((f = fopen(filename, "rb")) == NULL)
+ return error("Could not open %s", filename);
+ ptr->ptr = xmalloc(st.st_size);
+ if (fread(ptr->ptr, st.st_size, 1, f) != 1)
+ return error("Could not read %s", filename);
+ fclose(f);
+ ptr->size = st.st_size;
+ return 0;
+}
+
+
diff --git a/xdiff-interface.h b/xdiff-interface.h
index 1346908bea31319aabeabdfd955e2ea9aab37456..1918808081c00daf20a16a1592c0ed9be6d79be4 100644 (file)
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
int parse_hunk_header(char *line, int len,
int *ob, int *on,
int *nb, int *nn);
+int read_mmfile(mmfile_t *ptr, const char *filename);
#endif