path: root/convert.c
diff options
authorJunio C Hamano <>2011-05-12 21:31:08 (GMT)
committerJunio C Hamano <>2011-05-21 01:46:58 (GMT)
commitdd8e912190540ef6578386aa1343fbbe196cb8c1 (patch)
treef66b651a6c060a07a280d0d6aa73cd21c134b1e8 /convert.c
parent46bf043807cc5d8986f41139a8c28491f613c5e0 (diff)
streaming_write_entry(): use streaming API in write_entry()
When the output to a path does not have to be converted, we can read from the object database from the streaming API and write to the file in the working tree, without having to hold everything in the memory. The ident, auto- and safe- crlf conversions inherently require you to read the whole thing before deciding what to do, so while it is technically possible to support them by using a buffer of an unbound size or rewinding and reading the stream twice, it is less practical than the traditional "read the whole thing in core and convert" approach. Adding streaming filters for the other conversions on top of this should be doable by tweaking the can_bypass_conversion() function (it should be renamed to can_filter_stream() when it happens). Then the streaming API can be extended to wrap the git_istream streaming_write_entry() opens on the underlying object in another git_istream that reads from it, filters what is read, and let the streaming_write_entry() read the filtered result. But that is outside the scope of this series. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'convert.c')
1 files changed, 23 insertions, 0 deletions
diff --git a/convert.c b/convert.c
index efc7e07..d3c0041 100644
--- a/convert.c
+++ b/convert.c
@@ -813,3 +813,26 @@ int renormalize_buffer(const char *path, const char *src, size_t len, struct str
return ret | convert_to_git(path, src, len, dst, 0);
+ * You would be crazy to set CRLF, smuge/clean or ident to
+ * a large binary blob you would want us not to slurp into
+ * the memory!
+ */
+int can_bypass_conversion(const char *path)
+ struct conv_attrs ca;
+ enum crlf_action crlf_action;
+ convert_attrs(&ca, path);
+ if (ca.ident ||
+ (ca.drv && (ca.drv->smudge || ca.drv->clean)))
+ return 0;
+ crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);
+ if ((crlf_action == CRLF_BINARY) ||
+ (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE))
+ return 1;
+ return 0;