diff options
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c index d0f2aa029b..52e5c6fe46 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -3275,6 +3275,7 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size, { int ret, re_allocated = 0; int write_object = flags & HASH_WRITE_OBJECT; + const int valid_sha1 = flags & HASH_USE_SHA_NOT_PATH; if (!type) type = OBJ_BLOB; @@ -3285,7 +3286,8 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size, if ((type == OBJ_BLOB) && path) { struct strbuf nbuf = STRBUF_INIT; if (convert_to_git(path, buf, size, &nbuf, - write_object ? safe_crlf : SAFE_CRLF_FALSE)) { + write_object ? safe_crlf : SAFE_CRLF_FALSE, + valid_sha1 ? sha1 : NULL)) { buf = strbuf_detach(&nbuf, &size); re_allocated = 1; } @@ -3313,13 +3315,15 @@ static int index_stream_convert_blob(unsigned char *sha1, int fd, { int ret; const int write_object = flags & HASH_WRITE_OBJECT; + const int valid_sha1 = flags & HASH_USE_SHA_NOT_PATH; struct strbuf sbuf = STRBUF_INIT; assert(path); assert(would_convert_to_git_filter_fd(path)); convert_to_git_filter_fd(path, fd, &sbuf, - write_object ? safe_crlf : SAFE_CRLF_FALSE); + write_object ? safe_crlf : SAFE_CRLF_FALSE, + valid_sha1 ? sha1 : NULL); if (write_object) ret = write_sha1_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB), @@ -3396,6 +3400,8 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags) { int ret; + const unsigned char *sha1_ce; + sha1_ce = flags & HASH_USE_SHA_NOT_PATH ? sha1 : NULL; /* * Call xsize_t() only when needed to avoid potentially unnecessary @@ -3406,7 +3412,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, else if (!S_ISREG(st->st_mode)) ret = index_pipe(sha1, fd, type, path, flags); else if (st->st_size <= big_file_threshold || type != OBJ_BLOB || - (path && would_convert_to_git(path))) + (path && would_convert_to_git(path,sha1_ce))) ret = index_core(sha1, fd, xsize_t(st->st_size), type, path, flags); else |