2 * Licensed under a two-clause BSD-style license.
3 * See LICENSE for details.
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
)
21 pool_print_seq(depth
, path
, '/', stdout
);
25 void fast_export_modify(uint32_t depth
, uint32_t *path
, uint32_t mode
,
28 /* Mode must be 100644, 100755, 120000, or 160000. */
29 printf("M %06"PRIo32
" :%"PRIu32
" ", mode
, mark
);
30 pool_print_seq(depth
, path
, '/', stdout
);
34 static char gitsvnline
[MAX_GITSVN_LINE_LEN
];
35 void fast_export_commit(uint32_t revision
, uint32_t author
, char *log
,
36 uint32_t uuid
, uint32_t url
,
37 unsigned long timestamp
)
42 snprintf(gitsvnline
, MAX_GITSVN_LINE_LEN
,
43 "\n\ngit-svn-id: %s@%"PRIu32
" %s\n",
44 pool_fetch(url
), revision
, pool_fetch(uuid
));
48 printf("commit refs/heads/master\n");
49 printf("committer %s <%s@%s> %ld +0000\n",
50 ~author
? pool_fetch(author
) : "nobody",
51 ~author
? pool_fetch(author
) : "nobody",
52 ~uuid
? pool_fetch(uuid
) : "local", timestamp
);
53 printf("data %"PRIu32
"\n%s%s\n",
54 (uint32_t) (strlen(log
) + strlen(gitsvnline
)),
56 if (!first_commit_done
) {
58 printf("from refs/heads/master^0\n");
59 first_commit_done
= 1;
61 repo_diff(revision
- 1, revision
);
64 printf("progress Imported commit %"PRIu32
".\n\n", revision
);
67 void fast_export_blob(uint32_t mode
, uint32_t mark
, uint32_t len
, struct line_buffer
*input
)
69 if (mode
== REPO_MODE_LNK
) {
70 /* svn symlink blobs start with "link " */
71 buffer_skip_bytes(input
, 5);
74 printf("blob\nmark :%"PRIu32
"\ndata %"PRIu32
"\n", mark
, len
);
75 buffer_copy_bytes(input
, len
);