git p4 test: copy source indeterminate
[git/mjg.git] / test-svn-fe.c
blob332a5f711df8f3e3fea3305eb5ecb10de5581033
1 /*
2 * test-svn-fe: Code to exercise the svn import lib
3 */
5 #include "git-compat-util.h"
6 #include "vcs-svn/svndump.h"
7 #include "vcs-svn/svndiff.h"
8 #include "vcs-svn/sliding_window.h"
9 #include "vcs-svn/line_buffer.h"
11 static const char test_svnfe_usage[] =
12 "test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)";
14 static int apply_delta(int argc, char *argv[])
16 struct line_buffer preimage = LINE_BUFFER_INIT;
17 struct line_buffer delta = LINE_BUFFER_INIT;
18 struct sliding_view preimage_view = SLIDING_VIEW_INIT(&preimage, -1);
20 if (argc != 5)
21 usage(test_svnfe_usage);
23 if (buffer_init(&preimage, argv[2]))
24 die_errno("cannot open preimage");
25 if (buffer_init(&delta, argv[3]))
26 die_errno("cannot open delta");
27 if (svndiff0_apply(&delta, (off_t) strtoull(argv[4], NULL, 0),
28 &preimage_view, stdout))
29 return 1;
30 if (buffer_deinit(&preimage))
31 die_errno("cannot close preimage");
32 if (buffer_deinit(&delta))
33 die_errno("cannot close delta");
34 buffer_reset(&preimage);
35 strbuf_release(&preimage_view.buf);
36 buffer_reset(&delta);
37 return 0;
40 int main(int argc, char *argv[])
42 if (argc == 2) {
43 if (svndump_init(argv[1]))
44 return 1;
45 svndump_read(NULL);
46 svndump_deinit();
47 svndump_reset();
48 return 0;
51 if (argc >= 2 && !strcmp(argv[1], "-d"))
52 return apply_delta(argc, argv);
53 usage(test_svnfe_usage);