Since the cat() function in git.py is used only inside the server-cmd.py
script, and since it is a discouraged use of CatPipe, inline the code
inside the server-cmd.py script.
At the same time, make the CatPipe object persistent between calls to
the "cat" command to remove unnecessary deletion/creation or resources.
Signed-off-by: Gabriel Filion <lelutin@gmail.com>
conn.ok()
+cat_pipe = None
def cat(conn, id):
+ global cat_pipe
git.check_repo_or_die()
+ if not cat_pipe:
+ cat_pipe = git.CatPipe()
try:
- for blob in git.cat(id):
+ for blob in cat_pipe.join(id):
conn.write(struct.pack('!I', len(blob)))
conn.write(blob)
except KeyError, e:
yield d
except StopIteration:
log('booger!\n')
-
-
-def cat(id):
- c = CatPipe()
- for d in c.join(id):
- yield d