From 4fe5cfa0e063a8d51a1eb6f014e2aaa994e5e7d4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 22 Oct 2009 12:28:04 +0200 Subject: Stream_data streams data to a given output stream most efficiently with a low memory footprint. Still, the git-cat-file command keeps all data in an interal buffer instead of streaming it directly. This is a git design issue though, and will be hard to address without some proper git-hacking. Conflicts: lib/git/cmd.py --- lib/git/objects/base.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/git/objects/base.py') diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py index dd67a3c7..0dfd1a23 100644 --- a/lib/git/objects/base.py +++ b/lib/git/objects/base.py @@ -127,6 +127,18 @@ class Object(LazyMixin): proc = self.repo.git.cat_file(self.type, self.id, as_process=True) return utils.ProcessStreamAdapter(proc, "stdout") + def stream_data(self, ostream): + """ + Writes our data directly to the given output stream + + ``ostream`` + File object compatible stream object. + + Returns + self + """ + self.repo.git.cat_file(self.type, self.id, output_stream=ostream) + return self class IndexObject(Object): """ -- cgit v1.2.1