The magic number of svn deltas is SVN followed by a null byte. An alternative format (with compressed text) uses magic number SVN\1, but that is deprecated in favor of compressing the deltas as a whole as far as I can tell. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- vcs-svn/svndiff.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c index 4d122a5..df0b1a2 100644 --- a/vcs-svn/svndiff.c +++ b/vcs-svn/svndiff.c @@ -11,6 +11,7 @@ * * See http://svn.apache.org/repos/asf/subversion/trunk/notes/svndiff. * + * svndiff0 ::= 'SVN\0' window window*; * int ::= highdigit* lowdigit; * highdigit ::= # binary 1000 0000 OR-ed with 7 bit value; * lowdigit ::= # 7 bit value; @@ -20,6 +21,23 @@ #define VLI_DIGIT_MASK 0x7f #define VLI_BITS_PER_DIGIT 7 +static int read_magic(struct line_buffer *in, off_t *len) +{ + static const char magic[] = {'S', 'V', 'N', '\0'}; + struct strbuf sb = STRBUF_INIT; + if (*len < sizeof(magic)) + return error("Invalid delta: no file type header"); + buffer_read_binary(&sb, sizeof(magic), in); + if (sb.len != sizeof(magic)) + return error("Invalid delta: no file type header"); + if (memcmp(sb.buf, magic, sizeof(magic))) + return error("Unrecognized file type %.*s", + (int) sizeof(magic), sb.buf); + *len -= sizeof(magic); + strbuf_release(&sb); + return 0; +} + static int read_int(struct line_buffer *in, uintmax_t *result, off_t *len) { off_t sz = *len; -- 1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html