summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorMiriam Rubio <mirucam@gmail.com>2019-10-28 16:55:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-29 02:54:23 (GMT)
commit6c020421390e9470b6e1a2e16e6978c239973bb5 (patch)
tree8f5a09147c0d7f31714b471bc56f2cd09165b05f /builtin/clone.c
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
downloadgit-6c020421390e9470b6e1a2e16e6978c239973bb5.zip
git-6c020421390e9470b6e1a2e16e6978c239973bb5.tar.gz
git-6c020421390e9470b6e1a2e16e6978c239973bb5.tar.bz2
clone: rename static function `dir_exists()`.
builtin/clone.c has a static function dir_exists() that checks if a given path exists on the filesystem. It returns true (and it is correct for it to return true) when the given path exists as a non-directory (e.g. a regular file). This is confusing. What the caller wants to check, and what this function wants to return, is if the path exists, so rename it to path_exists(). Signed-off-by: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index f665b28..b264420 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -900,7 +900,7 @@ static void dissociate_from_references(void)
free(alternates);
}
-static int dir_exists(const char *path)
+static int path_exists(const char *path)
{
struct stat sb;
return !stat(path, &sb);
@@ -982,7 +982,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
dir = guess_dir_name(repo_name, is_bundle, option_bare);
strip_trailing_slashes(dir);
- dest_exists = dir_exists(dir);
+ dest_exists = path_exists(dir);
if (dest_exists && !is_empty_dir(dir))
die(_("destination path '%s' already exists and is not "
"an empty directory."), dir);
@@ -993,7 +993,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
work_tree = NULL;
else {
work_tree = getenv("GIT_WORK_TREE");
- if (work_tree && dir_exists(work_tree))
+ if (work_tree && path_exists(work_tree))
die(_("working tree '%s' already exists."), work_tree);
}
@@ -1021,7 +1021,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
if (real_git_dir) {
- if (dir_exists(real_git_dir))
+ if (path_exists(real_git_dir))
junk_git_dir_flags |= REMOVE_DIR_KEEP_TOPLEVEL;
junk_git_dir = real_git_dir;
} else {