Skip to contentSkip to conversation

convert: add functions to check if we can bypass conversion

RFC PATCH New Nguyễn Thái Ngọc Duy 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 convert: add functions to check if we can bypass conversion

Blob conversion from/to repository requires the entire blob in memory. The conversion is rarely used most of the time and that requirement could put pressure on memory for large blobs.

Add two functions to determine early whether we can bypass conversion without looking at the content.

---
I have patches to checkout loose objects directly to working tree but they are ugly and do not support packs. We probably should flag deltified objects as "conversion required" too.

Anyway I think the intention of this patch is good. Whatever we are going to do with large blobs wrt memory usage, we need to cut this part out, or support streaming conversion interface. I doubt the latter would come.

 cache.h   |    3 ++
 convert.c |   79 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 65 insertions(+), 17 deletions(-)
cache.h +3 -0
index 08a9022..be3845d 100644
@@ -1091,7 +1091,10 @@ extern void trace_repo_setup(const char *prefix);
 /* returns 1 if *dst was used */
 extern int convert_to_git(const char *path, const char *src, size_t len,
                           struct strbuf *dst, enum safe_crlf checksafe);
+extern int convert_to_git_needed(const char *path, size_t len,
+				 enum safe_crlf checksafe);
 extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst);
+extern int convert_to_working_tree_needed(const char *path, size_t len);
 extern int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst);
 
 /* add */
convert.c +62 -17

187 lines not on this page · raw message

Signature · 1 line
1.7.4.74.g639db