git-svn: Reduce temp file usage when dealing with non-links
commit510b0945d041752db2f53dda00f1188308e2df4e
authorMarcus Griep <marcus@griep.us>
Tue, 12 Aug 2008 16:45:39 +0000 (12 12:45 -0400)
committerEric Wong <normalperson@yhbt.net>
Wed, 13 Aug 2008 03:46:54 +0000 (12 20:46 -0700)
tree366139afae9a443a3f32184ee2d79bf26c5e5e4b
parent0b19138ba3e4c129770565d364df65ec25ca0a8e
git-svn: Reduce temp file usage when dealing with non-links

Currently, in sub 'close_file', git-svn creates a temporary file and
copies the contents of the blob to be written into it. This is useful
for symlinks because svn stores symlinks in the form:

link $FILE_PATH

Git creates a blob only out of '$FILE_PATH' and uses file mode to
indicate that the blob should be interpreted as a symlink.

As git-hash-object is invoked with --stdin-paths, a duplicate of the
link from svn must be created that leaves off the first five bytes,
i.e. 'link '. However, this is wholly unnecessary for normal blobs,
though, as we already have a temp file with their contents. Copying
the entire file gains nothing, and effectively requires a file to be
written twice before making it into the object db.

This patch corrects that issue, holding onto the substr-like
duplication for symlinks, but skipping it altogether for normal blobs
by reusing the existing temp file.

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl