Resolve segfault on reset of non-persistent pools.
[svn-fe.git] / fast_export.c
blob56e5afa7e8741ce3236087480f6ba561715a5962
1 /*
2 * Licensed under a two-clause BSD-style license.
3 * See LICENSE for details.
4 */
6 #include <string.h>
8 #include "fast_export.h"
9 #include "line_buffer.h"
10 #include "repo_tree.h"
11 #include "string_pool.h"
13 #define MAX_GITSVN_LINE_LEN 4096
15 static uint32_t first_commit_done;
17 void fast_export_delete(uint32_t depth, uint32_t *path)
19 putchar('D');
20 putchar(' ');
21 pool_print_seq(depth, path, '/', stdout);
22 putchar('\n');
25 void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
26 uint32_t mark)
28 printf("M %06o :%d ", mode, mark);
29 pool_print_seq(depth, path, '/', stdout);
30 putchar('\n');
33 static char gitsvnline[MAX_GITSVN_LINE_LEN];
34 void fast_export_commit(uint32_t revision, uint32_t author, char *log,
35 uint32_t uuid, uint32_t url, time_t timestamp)
37 if (!log)
38 log = "";
39 if (~uuid && ~url) {
40 snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%d %s\n",
41 pool_fetch(url), revision, pool_fetch(uuid));
42 } else {
43 *gitsvnline = '\0';
45 printf("commit refs/heads/master\n");
46 printf("committer %s <%s@%s> %ld +0000\n",
47 ~author ? pool_fetch(author) : "nobody",
48 ~author ? pool_fetch(author) : "nobody",
49 ~uuid ? pool_fetch(uuid) : "local", timestamp);
50 printf("data %zd\n%s%s\n",
51 strlen(log) + strlen(gitsvnline), log, gitsvnline);
52 if (!first_commit_done) {
53 if (revision > 1)
54 printf("from refs/heads/master^0\n");
55 first_commit_done = 1;
57 repo_diff(revision - 1, revision);
58 fputc('\n', stdout);
60 printf("progress Imported commit %d.\n\n", revision);
63 void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)
65 if (mode == REPO_MODE_LNK) {
66 /* svn symlink blobs start with "link " */
67 buffer_skip_bytes(5);
68 len -= 5;
70 printf("blob\nmark :%d\ndata %d\n", mark, len);
71 buffer_copy_bytes(len);
72 fputc('\n', stdout);