2010-08-10 00:48:10 +02:00
|
|
|
/*
|
|
|
|
* Licensed under a two-clause BSD-style license.
|
|
|
|
* See LICENSE for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "git-compat-util.h"
|
|
|
|
#include "fast_export.h"
|
|
|
|
#include "line_buffer.h"
|
|
|
|
#include "repo_tree.h"
|
|
|
|
#include "string_pool.h"
|
|
|
|
|
|
|
|
#define MAX_GITSVN_LINE_LEN 4096
|
|
|
|
|
|
|
|
static uint32_t first_commit_done;
|
|
|
|
|
|
|
|
void fast_export_delete(uint32_t depth, uint32_t *path)
|
|
|
|
{
|
|
|
|
putchar('D');
|
|
|
|
putchar(' ');
|
|
|
|
pool_print_seq(depth, path, '/', stdout);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode,
|
|
|
|
uint32_t mark)
|
|
|
|
{
|
|
|
|
/* Mode must be 100644, 100755, 120000, or 160000. */
|
2010-09-09 19:24:06 +02:00
|
|
|
printf("M %06"PRIo32" :%"PRIu32" ", mode, mark);
|
2010-08-10 00:48:10 +02:00
|
|
|
pool_print_seq(depth, path, '/', stdout);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
static char gitsvnline[MAX_GITSVN_LINE_LEN];
|
|
|
|
void fast_export_commit(uint32_t revision, uint32_t author, char *log,
|
|
|
|
uint32_t uuid, uint32_t url,
|
|
|
|
unsigned long timestamp)
|
|
|
|
{
|
|
|
|
if (!log)
|
|
|
|
log = "";
|
|
|
|
if (~uuid && ~url) {
|
2010-09-09 19:24:06 +02:00
|
|
|
snprintf(gitsvnline, MAX_GITSVN_LINE_LEN,
|
|
|
|
"\n\ngit-svn-id: %s@%"PRIu32" %s\n",
|
2010-08-10 00:48:10 +02:00
|
|
|
pool_fetch(url), revision, pool_fetch(uuid));
|
|
|
|
} else {
|
|
|
|
*gitsvnline = '\0';
|
|
|
|
}
|
|
|
|
printf("commit refs/heads/master\n");
|
|
|
|
printf("committer %s <%s@%s> %ld +0000\n",
|
|
|
|
~author ? pool_fetch(author) : "nobody",
|
|
|
|
~author ? pool_fetch(author) : "nobody",
|
|
|
|
~uuid ? pool_fetch(uuid) : "local", timestamp);
|
2010-08-14 02:03:17 +02:00
|
|
|
printf("data %"PRIu32"\n%s%s\n",
|
|
|
|
(uint32_t) (strlen(log) + strlen(gitsvnline)),
|
|
|
|
log, gitsvnline);
|
2010-08-10 00:48:10 +02:00
|
|
|
if (!first_commit_done) {
|
|
|
|
if (revision > 1)
|
|
|
|
printf("from refs/heads/master^0\n");
|
|
|
|
first_commit_done = 1;
|
|
|
|
}
|
|
|
|
repo_diff(revision - 1, revision);
|
|
|
|
fputc('\n', stdout);
|
|
|
|
|
2010-09-09 19:24:06 +02:00
|
|
|
printf("progress Imported commit %"PRIu32".\n\n", revision);
|
2010-08-10 00:48:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len)
|
|
|
|
{
|
|
|
|
if (mode == REPO_MODE_LNK) {
|
|
|
|
/* svn symlink blobs start with "link " */
|
|
|
|
buffer_skip_bytes(5);
|
|
|
|
len -= 5;
|
|
|
|
}
|
2010-09-09 19:24:06 +02:00
|
|
|
printf("blob\nmark :%"PRIu32"\ndata %"PRIu32"\n", mark, len);
|
2010-08-10 00:48:10 +02:00
|
|
|
buffer_copy_bytes(len);
|
|
|
|
fputc('\n', stdout);
|
|
|
|
}
|