]>
Commit | Line | Data |
---|---|---|
c0e6c23d DB |
1 | /* |
2 | * Licensed under a two-clause BSD-style license. | |
3 | * See LICENSE for details. | |
4 | */ | |
5 | ||
6 | #include "git-compat-util.h" | |
7 | #include "fast_export.h" | |
8 | #include "line_buffer.h" | |
9 | #include "repo_tree.h" | |
10 | #include "string_pool.h" | |
11 | ||
12 | #define MAX_GITSVN_LINE_LEN 4096 | |
13 | ||
14 | static uint32_t first_commit_done; | |
15 | ||
16 | void fast_export_delete(uint32_t depth, uint32_t *path) | |
17 | { | |
18 | putchar('D'); | |
19 | putchar(' '); | |
20 | pool_print_seq(depth, path, '/', stdout); | |
21 | putchar('\n'); | |
22 | } | |
23 | ||
24 | void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode, | |
25 | uint32_t mark) | |
26 | { | |
27 | /* Mode must be 100644, 100755, 120000, or 160000. */ | |
28 | printf("M %06o :%d ", mode, mark); | |
29 | pool_print_seq(depth, path, '/', stdout); | |
30 | putchar('\n'); | |
31 | } | |
32 | ||
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, | |
36 | unsigned long timestamp) | |
37 | { | |
38 | if (!log) | |
39 | log = ""; | |
40 | if (~uuid && ~url) { | |
41 | snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%d %s\n", | |
42 | pool_fetch(url), revision, pool_fetch(uuid)); | |
43 | } else { | |
44 | *gitsvnline = '\0'; | |
45 | } | |
46 | printf("commit refs/heads/master\n"); | |
47 | printf("committer %s <%s@%s> %ld +0000\n", | |
48 | ~author ? pool_fetch(author) : "nobody", | |
49 | ~author ? pool_fetch(author) : "nobody", | |
50 | ~uuid ? pool_fetch(uuid) : "local", timestamp); | |
6117abae JN |
51 | printf("data %"PRIu32"\n%s%s\n", |
52 | (uint32_t) (strlen(log) + strlen(gitsvnline)), | |
53 | log, gitsvnline); | |
c0e6c23d DB |
54 | if (!first_commit_done) { |
55 | if (revision > 1) | |
56 | printf("from refs/heads/master^0\n"); | |
57 | first_commit_done = 1; | |
58 | } | |
59 | repo_diff(revision - 1, revision); | |
60 | fputc('\n', stdout); | |
61 | ||
62 | printf("progress Imported commit %d.\n\n", revision); | |
63 | } | |
64 | ||
65 | void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len) | |
66 | { | |
67 | if (mode == REPO_MODE_LNK) { | |
68 | /* svn symlink blobs start with "link " */ | |
69 | buffer_skip_bytes(5); | |
70 | len -= 5; | |
71 | } | |
72 | printf("blob\nmark :%d\ndata %d\n", mark, len); | |
73 | buffer_copy_bytes(len); | |
74 | fputc('\n', stdout); | |
75 | } |