summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-05-06 06:45:53 -0700
committerVicent Martí <vicent@github.com>2013-05-06 06:45:53 -0700
commit03c28d92d00074f1501cb0d7ce9f5e3e0154a244 (patch)
tree64c394dc10a839fd0766a800ff31a1d0236360d6 /src/clone.c
parentd5e5bbd7193924aa845e107f747a15814a679b10 (diff)
parent6e286e8dc59874db30b6fbb0ca5d32d4a2b5642c (diff)
downloadlibgit2-03c28d92d00074f1501cb0d7ce9f5e3e0154a244.tar.gz
Merge pull request #1526 from arrbee/cleanup-error-return-without-msg
Make sure error messages are set for most error returns
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 9cde6f6bd..38c0d409e 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -397,18 +397,6 @@ on_error:
}
-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,
@@ -454,7 +442,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", local_path);
return GIT_ERROR;
}