Subject: [PATCH 03/10] vcs-svn: introduce cat_mark function to retrieve a marked blob

From: Jonathan Nieder <[email-masked]>
Date: Fri, 10 Dec 2010 04:23:03 -0600

Signed-off-by: Jonathan Nieder <[email-masked]>
---
A blind alley.  But it demonstrates how this works.

 vcs-svn/fast_export.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index 093ce1d..daac201 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -116,6 +116,19 @@ static const char *get_response_line(void)
 	return response_line.buf;
 }
 
+static off_t cat_mark(uint32_t mark)
+{
+	const char *response;
+	off_t length = length;
+
+	printf("cat-blob :%"PRIu32"\n", mark);
+	fflush(stdout);
+	response = get_response_line();
+	if (parse_cat_response_line(response, &length))
+		die("invalid cat-blob response: %s", response);
+	return length;
+}
+
 static long apply_delta(uint32_t mark, off_t len, struct line_buffer *input,
 			uint32_t old_mark, uint32_t old_mode)
 {
@@ -126,14 +139,8 @@ static long apply_delta(uint32_t mark, off_t len, struct line_buffer *input,
 
 	if (init_postimage() || !(out = buffer_tmpfile_rewind(&postimage)))
 		die("cannot open temporary file for blob retrieval");
-	if (old_mark) {
-		const char *response;
-		printf("cat-blob :%"PRIu32"\n", old_mark);
-		fflush(stdout);
-		response = get_response_line();
-		if (parse_cat_response_line(response, &preimage_len))
-			die("invalid cat-blob response: %s", response);
-	}
+	if (old_mark)
+		preimage_len = cat_mark(old_mark);
 	if (old_mode == REPO_MODE_LNK) {
 		strbuf_addstr(&preimage.buf, "link ");
 		preimage_len += strlen("link ");
-- 
1.7.2.4