When conversion attributes have changed, it is useful to be able to easily reconvert an existing blob. Signed-off-by: Henrik Grubbström <grubba@xxxxxxxxxx> --- No changes since v1. cache.h | 1 + sha1_file.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/cache.h b/cache.h index 5eb0573..1fe2d7d 100644 --- a/cache.h +++ b/cache.h @@ -494,6 +494,7 @@ extern int ie_match_stat(const struct index_state *, struct cache_entry *, struc extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); extern int ce_path_match(const struct cache_entry *ce, const char **pathspec); +extern int index_blob(unsigned char *dst_sha1, const unsigned char *src_sha1, int write_object, const char *path); extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path); extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object); extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); diff --git a/sha1_file.c b/sha1_file.c index ff65328..c162321 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2434,6 +2434,25 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size, #define SMALL_FILE_SIZE (32*1024) +int index_blob(unsigned char *dst_sha1, const unsigned char *src_sha1, + int write_object, const char *path) +{ + void *buf; + unsigned long buflen = 0; + int ret; + + memcpy(dst_sha1, src_sha1, 20); + buf = read_object_with_reference(src_sha1, typename(OBJ_BLOB), + &buflen, dst_sha1); + if (!buf) + return 0; + + ret = index_mem(dst_sha1, buf, buflen, write_object, OBJ_BLOB, path); + free(buf); + + return ret; +} + int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path) { -- 1.7.0.4.369.g81e89 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html