diff options
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r-- | xdiff-interface.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c index d782f06d99..ca5e3fbae8 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -15,11 +15,10 @@ static int parse_num(char **cp_p, int *num_p) { char *cp = *cp_p; int num = 0; - int read_some; while ('0' <= *cp && *cp <= '9') num = num * 10 + *cp++ - '0'; - if (!(read_some = cp - *cp_p)) + if (!(cp - *cp_p)) return -1; *cp_p = cp; *num_p = num; @@ -219,6 +218,23 @@ int read_mmfile(mmfile_t *ptr, const char *filename) return 0; } +void read_mmblob(mmfile_t *ptr, const unsigned char *sha1) +{ + unsigned long size; + enum object_type type; + + if (!hashcmp(sha1, null_sha1)) { + ptr->ptr = xstrdup(""); + ptr->size = 0; + return; + } + + ptr->ptr = read_sha1_file(sha1, &type, &size); + if (!ptr->ptr || type != OBJ_BLOB) + die("unable to read blob object %s", sha1_to_hex(sha1)); + ptr->size = size; +} + #define FIRST_FEW_BYTES 8000 int buffer_is_binary(const char *ptr, unsigned long size) { @@ -310,6 +326,21 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags) } } +void xdiff_clear_find_func(xdemitconf_t *xecfg) +{ + if (xecfg->find_func) { + int i; + struct ff_regs *regs = xecfg->find_func_priv; + + for (i = 0; i < regs->nr; i++) + regfree(®s->array[i].re); + free(regs->array); + free(regs); + xecfg->find_func = NULL; + xecfg->find_func_priv = NULL; + } +} + int git_xmerge_style = -1; int git_xmerge_config(const char *var, const char *value, void *cb) |