in focus/operations/src/clone.rs [446:514]
fn clone_local(
dense_repo_path: &Path,
sparse_repo_path: &Path,
branch: &str,
copy_branches: bool,
days_of_history: u64,
app: Arc<App>,
) -> Result<()> {
info!("Dense repo path: {}", dense_repo_path.display());
let dense_repo_path = if dense_repo_path.is_absolute() {
dense_repo_path.to_owned()
} else {
std::env::current_dir()
.expect("Failed determining current directory")
.join(dense_repo_path)
};
if !dense_repo_path.is_absolute() {
bail!("Dense repo path must be absolute");
}
if sparse_repo_path.is_dir() {
bail!("Sparse repo directory already exists");
}
enable_filtering(&dense_repo_path)
.context("setting configuration options in the dense repo")?;
let url = Url::from_file_path(&dense_repo_path)
.expect("Failed to convert dense repo path to a file URL");
{
let span = info_span!("Cloning", dense_repo_path = ?dense_repo_path, sparse_repo_path = ?sparse_repo_path);
let _guard = span.enter();
clone_shallow(
&url,
sparse_repo_path,
branch,
copy_branches,
days_of_history,
app.clone(),
)
.context("Failed to clone the repository")?;
}
let dense_repo = Repository::open(&dense_repo_path).context("Opening dense repo")?;
let sparse_repo = Repository::open(sparse_repo_path).context("Opening sparse repo")?;
if copy_branches {
let span = info_span!("Copying branches");
let _guard = span.enter();
copy_local_branches(
&dense_repo,
&sparse_repo,
branch,
app.clone(),
days_of_history,
)
.context("Failed to copy references")?;
}
set_up_remotes(&dense_repo, &sparse_repo, branch, app)
.context("Failed to set up the remotes")?;
copy_dense_config(&dense_repo, &sparse_repo)
.context("failed to copy config from dense repo")?;
Ok(())
}