@matheusbsbs / matheus-bagliano / commits / ef2ac77e9f
Fork 0

vcs-svn: read instructions from deltas

Buffer the instruction section upon encountering it for later interpretation. An alternative design would involve parsing the instructions at this point and buffering them in some processed form. Using the unprocessed form is simpler. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Ramkumar Ramachandra <artagnon@gmail.com>

Jonathan Nieder committed Oct 13, 2010 at 04:38 UTC ef2ac77e9f8f4819f75cf52721567463e60a805c
2 files changed +10 -2
t/t9011-svn-da.sh
+5
@@ -133,4 +133,9 @@ test_expect_success 'reject truncated inline data' '
133 test_must_fail test-svn-fe -d preimage inline.trunc 10
134 '
135
136 +test_expect_success 'reject truncated inline data (after instruction section)' '
137 + printf "SVNQ%b%b%s" "QQ\001\001\003" "\0201" "b" | q_to_nul >insn.trunc &&
138 + test_must_fail test-svn-fe -d preimage insn.trunc 11
139 +'
140 +
141 test_done
vcs-svn/svndiff.c
+5 -2
@@ -25,13 +25,15 @@
25 #define VLI_BITS_PER_DIGIT 7
26
27 struct window {
28 + struct strbuf instructions;
29 struct strbuf data;
30 };
31
31 -#define WINDOW_INIT { STRBUF_INIT }
32 +#define WINDOW_INIT { STRBUF_INIT, STRBUF_INIT }
33
34 static void window_release(struct window *ctx)
35 {
36 + strbuf_release(&ctx->instructions);
37 strbuf_release(&ctx->data);
38 }
39
@@ -124,7 +126,8 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len)
126 /* "source view" offset and length already handled; */
127 if (read_length(delta, &out_len, delta_len) ||
128 read_length(delta, &instructions_len, delta_len) ||
127 - read_length(delta, &data_len, delta_len))
129 + read_length(delta, &data_len, delta_len) ||
130 + read_chunk(delta, delta_len, &ctx.instructions, instructions_len))
131 goto error_out;
132 if (instructions_len) {
133 error("What do you think I am? A delta applier?");