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>
Miriam Rubio committed
Oct 28, 2019 at 17:55 UTC
6c020421390e9470b6e1a2e16e6978c239973bb5
1 file changed
+4
-4
builtin/clone.c
+4
-4
@@ -900,7 +900,7 @@ static void dissociate_from_references(void)
900
free(alternates);
901
}
902
903
-static int dir_exists(const char *path)
903
+static int path_exists(const char *path)
904
{
905
struct stat sb;
906
return !stat(path, &sb);
@@ -982,7 +982,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
982
dir = guess_dir_name(repo_name, is_bundle, option_bare);
983
strip_trailing_slashes(dir);
984
985
- dest_exists = dir_exists(dir);
985
+ dest_exists = path_exists(dir);
986
if (dest_exists && !is_empty_dir(dir))
987
die(_("destination path '%s' already exists and is not "
988
"an empty directory."), dir);
@@ -993,7 +993,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
993
work_tree = NULL;
994
else {
995
work_tree = getenv("GIT_WORK_TREE");
996
- if (work_tree && dir_exists(work_tree))
996
+ if (work_tree && path_exists(work_tree))
997
die(_("working tree '%s' already exists."), work_tree);
998
}
999
@@ -1021,7 +1021,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1021
}
1022
1023
if (real_git_dir) {
1024
- if (dir_exists(real_git_dir))
1024
+ if (path_exists(real_git_dir))
1025
junk_git_dir_flags |= REMOVE_DIR_KEEP_TOPLEVEL;
1026
junk_git_dir = real_git_dir;
1027
} else {