mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 18:22:16 +00:00
Simplify error reporting
This commit is contained in:
parent
3e199f4285
commit
f6f48f9008
17
src/clone.c
17
src/clone.c
@ -387,18 +387,6 @@ static int setup_remotes_and_fetch(
|
||||
}
|
||||
|
||||
|
||||
static bool path_is_okay(const char *path)
|
||||
{
|
||||
/* The path must either not exist, or be an empty directory */
|
||||
if (!git_path_exists(path)) return true;
|
||||
if (!git_path_is_empty_dir(path)) {
|
||||
giterr_set(GITERR_INVALID,
|
||||
"'%s' exists and is not an empty directory", path);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool should_checkout(
|
||||
git_repository *repo,
|
||||
bool is_bare,
|
||||
@ -444,7 +432,10 @@ int git_clone(
|
||||
normalize_options(&normOptions, options);
|
||||
GITERR_CHECK_VERSION(&normOptions, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
|
||||
|
||||
if (!path_is_okay(local_path)) {
|
||||
/* Only clone to a new directory or an empty directory */
|
||||
if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) {
|
||||
giterr_set(GITERR_INVALID,
|
||||
"'%s' exists and is not an empty directory", path);
|
||||
return GIT_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user