git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Status of the svn remote helper project (Nov 2010, #2)

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 21, 2010, 23:06 UTC
Message-ID
<20101121230613.GA24397@burratino>
In-Reply-To
<BB713021-7826-4E9E-8576-7D1704BF517C@cordelta.com>
David Michael Barr wrote:
> Jonathan Nieder wrote:
Show 5 quoted lines
>> A delta in r36 of <http://svn.apache.org/repos/asf> does not apply
>> with this brand of svn-fe.
>
> That's odd, I was able to import up to r354 before receiving:
> fatal: missing newline after cat-blob response

Apparently sometimes deltas use the whole preimage and sometimes they don't.

Here's a fix (still needs a simple reproduction script).
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/test-svn-fe.c b/test-svn-fe.c
index 64f63cf..71de02b 100644
--- a/test-svn-fe.c
+++ b/test-svn-fe.c
@@ -11,7 +11,7 @@
 int main(int argc, char *argv[])
 {
 	static const char test_svnfe_usage[] =
-		"test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)";
+		"test-svn-fe (<dumpfile> | [-d] <preimage> [<preimage len>] <delta> <len>)";
 	if (argc < 2)
 		usage(test_svnfe_usage);
 	if (argc == 2) {
@@ -22,16 +22,26 @@ int main(int argc, char *argv[])
 		svndump_reset();
 		return 0;
 	}
-	if (argc == 5 && !strcmp(argv[1], "-d")) {
+	if ((argc == 5 || argc == 6) && !strcmp(argv[1], "-d")) {
+		char **arg = argv + 2;
 		struct line_buffer delta = LINE_BUFFER_INIT;
-		int preimage_fd = open(argv[2], O_RDONLY);
+		int preimage_fd = open(*arg++, O_RDONLY);
 		struct view preimage_view = {preimage_fd, 0, STRBUF_INIT};
+		off_t preimage_len;
 		if (preimage_fd < 0)
 			die_errno("cannot open preimage");
-		if (buffer_init(&delta, argv[3]))
+		if (argc == 6) {
+			preimage_len = (off_t) strtoull(*arg++, NULL, 0);
+		} else {
+			struct stat st;
+			if (fstat(preimage_fd, &st))
+				die_errno("cannot stat preimage");
+			preimage_len = st.st_size;
+		}
+		if (buffer_init(&delta, *arg++))
 			die_errno("cannot open delta");
-		if (svndiff0_apply(&delta, (off_t) strtoull(argv[4], NULL, 0),
-				   &preimage_view, stdout))
+		if (svndiff0_apply(&delta, (off_t) strtoull(*arg++, NULL, 0),
+				   &preimage_view, preimage_len, stdout))
 			return 1;
 		if (close(preimage_fd))
 			die_errno("cannot close preimage");
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index ceb1fc5..02456cf 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -119,6 +119,7 @@ static long apply_delta(uint32_t mark, off_t len, struct line_buffer *input,
 			uint32_t old_mark, uint32_t old_mode)
 {
 	long ret;
+	off_t preimage_len = 0;
 	struct view preimage = {REPORT_FILENO, 0, STRBUF_INIT};
 	FILE *out;
 
@@ -130,13 +131,12 @@ static long apply_delta(uint32_t mark, off_t len, struct line_buffer *input,
 		printf("cat-blob :%"PRIu32"\n", old_mark);
 		fflush(stdout);
 		response = get_response_line();
-		/* Not necessary, just for robustness */
-		if (parse_cat_response_line(response, &dummy))
+		if (parse_cat_response_line(response, &preimage_len))
 			die("invalid cat-blob response: %s", response);
 	}
 	if (old_mode == REPO_MODE_LNK)
 		strbuf_addstr(&preimage.buf, "link ");
-	if (svndiff0_apply(input, len, &preimage, out))
+	if (svndiff0_apply(input, len, &preimage, preimage_len, out))
 		die("cannot apply delta");
 	if (old_mark) {
 		/* Discard trailing newline from cat-blob-fd. */
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 308c734..8210561 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -283,7 +283,8 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
 }
 
 int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
-			struct view *preimage_view, FILE *postimage)
+			struct view *preimage_view, off_t preimage_len,
+			FILE *postimage)
 {
 	assert(delta && preimage_view && postimage);
 
@@ -302,5 +303,7 @@ int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
 			return error("Delta ends early! (%"PRIu64" bytes remaining)",
 			      (uint64_t) delta_len);
 	}
+	if (move_window(preimage_view, preimage_len, 0))
+		return -1;
 	return 0;
 }
diff --git a/vcs-svn/svndiff.h b/vcs-svn/svndiff.h
index bb5afd0..640e04f 100644
--- a/vcs-svn/svndiff.h
+++ b/vcs-svn/svndiff.h
@@ -5,6 +5,7 @@
 #include "sliding_window.h"
 
 extern int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
-				struct view *preimage_view, FILE *postimage);
+				struct view *preimage_view, off_t preimage_len,
+				FILE *postimage);
 
 #endif
Previous: David Michael BarrNext: David Barr
Message 10 of 22 in “Status of the svn remote helper project (Nov, 2010)”
  1. Jonathan NiederNov 7, 2010
  2. David Michael BarrNov 7, 2010
  3. David BarrNov 8, 2010
  4. Jonathan NiederNov 8, 2010
  5. David BarrNov 8, 2010
  6. Ramkumar RamachandraNov 7, 2010
  7. Jonathan NiederNov 7, 2010
  8. Status of the svn remote helper project (Nov 2010, #2)Jonathan Nieder, Nov 21, 2010
  9. David Michael BarrNov 21, 2010
  10. Jonathan NiederNov 21, 2010
  11. David BarrNov 22, 2010
  12. Status of the svn remote helper project (Dec 2010, #1)Jonathan Nieder, Dec 5, 2010
  13. Tomas CarneckyDec 8, 2010
  14. fast-import tweaks for remote helpers (Re: Status of the svn remote helper project (Dec 2010, #1))Jonathan Nieder, Dec 12, 2010
  15. Sam VilainDec 12, 2010
  16. Jonathan NiederDec 12, 2010
  17. fast-import --report-fd (Re: fast-import tweaks for remote helpers)Jonathan Nieder, Jan 5, 2011
  18. Status of the svn remote helper project (Jan 2011, #1)Jonathan Nieder, Jan 5, 2011
  19. David Michael BarrJan 7, 2011
  20. Plans for the vcs-svn-pu branchJonathan Nieder, Feb 11, 2011
  21. svn-fe: warn about experimental statusJonathan Nieder, Feb 11, 2011
  22. Ramkumar RamachandraFeb 11, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.