Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-05-01 15:57:05 +0400
committerRussell Belfer <rb@github.com>2013-05-01 15:57:05 +0400
commitf6f48f9008a9aaba5cbcfc611b616d8ae332b5e3 (patch)
treec79585021eddb95543647ba7aaecdcb32b14e6d4 /src/clone.c
parent3e199f428513fbf04b126d536409deae1c6d045f (diff)
Simplify error reporting
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/clone.c b/src/clone.c
index aeb7bbf5c..a19788699 100644
--- a/src/clone.c
+++ b/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;
}