2010-08-09 22:48:10 +00:00
|
|
|
/*
|
|
|
|
* Licensed under a two-clause BSD-style license.
|
|
|
|
* See LICENSE for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "git-compat-util.h"
|
2010-12-10 10:00:55 +00:00
|
|
|
#include "strbuf.h"
|
2010-08-09 22:48:10 +00:00
|
|
|
#include "repo_tree.h"
|
|
|
|
#include "fast_export.h"
|
|
|
|
|
2011-05-26 07:12:14 +00:00
|
|
|
const char *repo_read_path(const char *path, uint32_t *mode_out)
|
2010-08-09 22:48:10 +00:00
|
|
|
{
|
2010-12-10 10:00:55 +00:00
|
|
|
int err;
|
|
|
|
static struct strbuf buf = STRBUF_INIT;
|
2010-08-09 22:48:10 +00:00
|
|
|
|
2010-12-10 10:00:55 +00:00
|
|
|
strbuf_reset(&buf);
|
2011-05-26 07:12:14 +00:00
|
|
|
err = fast_export_ls(path, mode_out, &buf);
|
2010-12-10 10:00:55 +00:00
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls error");
|
2010-12-13 06:09:31 +00:00
|
|
|
/* Treat missing paths as directories. */
|
|
|
|
*mode_out = REPO_MODE_DIR;
|
2010-08-09 22:48:10 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-10 10:00:55 +00:00
|
|
|
return buf.buf;
|
vcs-svn: introduce repo_read_path to check the content at a path
The repo_tree structure remembers, for each path in each revision, a
mode (regular file, executable, symlink, or directory) and content
(blob mark or directory structure). Maintaining a second copy of all
this information when it's already in the target repository is
wasteful, it does not persist between svn-fe invocations, and most
importantly, there is no convenient way to transfer it from one
machine to another. So it would be nice to get rid of it.
As a first step, let's change the repo_tree API to match fast-import's
read commands more closely. Currently to read the mode for a path,
one uses
repo_modify_path(path, new_mode, new_content);
which changes the mode and content as a side effect. There is no
function to read the content at a path; add one.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2010-11-20 19:25:28 +00:00
|
|
|
}
|
|
|
|
|
2010-12-13 05:41:12 +00:00
|
|
|
void repo_copy(uint32_t revision, const char *src, const char *dst)
|
2010-08-09 22:48:10 +00:00
|
|
|
{
|
2010-12-10 10:00:55 +00:00
|
|
|
int err;
|
|
|
|
uint32_t mode;
|
|
|
|
static struct strbuf data = STRBUF_INIT;
|
|
|
|
|
|
|
|
strbuf_reset(&data);
|
2010-12-13 05:41:12 +00:00
|
|
|
err = fast_export_ls_rev(revision, src, &mode, &data);
|
2010-12-10 10:00:55 +00:00
|
|
|
if (err) {
|
|
|
|
if (errno != ENOENT)
|
|
|
|
die_errno("BUG: unexpected fast_export_ls_rev error");
|
2010-12-13 05:41:12 +00:00
|
|
|
fast_export_delete(dst);
|
2010-12-10 10:00:55 +00:00
|
|
|
return;
|
2010-08-09 22:48:10 +00:00
|
|
|
}
|
2010-12-13 05:41:12 +00:00
|
|
|
fast_export_modify(dst, mode, data.buf);
|
2010-08-09 22:48:10 +00:00
|
|
|
}
|
|
|
|
|
2010-12-13 05:41:12 +00:00
|
|
|
void repo_delete(const char *path)
|
2010-08-09 22:48:10 +00:00
|
|
|
{
|
2010-12-13 05:41:12 +00:00
|
|
|
fast_export_delete(path);
|
2010-08-09 22:48:10 +00:00
|
|
|
}
|