X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=xdiff-interface.c;h=e1e054e4d982de30d8a9c8c4109c6d62448f62a9;hb=414e569e453a49171b1f3db613f88378324104e8;hp=3cf39c39c47301fb39cbe859d5165179c13fe752;hpb=28bf4ba014c9b41679f41580fa9e1cc294b240d9;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index 3cf39c39c..e1e054e4d 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -219,6 +219,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) { @@ -269,9 +286,8 @@ static long ff_regexp(const char *line, long len, result = pmatch[i].rm_eo - pmatch[i].rm_so; if (result > buffer_size) result = buffer_size; - else - while (result > 0 && (isspace(line[result - 1]))) - result--; + while (result > 0 && (isspace(line[result - 1]))) + result--; memcpy(buffer, line, result); fail: free(line_buffer);