]> git.proxmox.com Git - libgit2.git/blobdiff - tests/repo/discover.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / tests / repo / discover.c
index 48aa27581c1a5333df7da2303014a60c08a6b135..c026eefc3100366c34c6d2a190b3de6199eb3ef1 100644 (file)
@@ -1,7 +1,7 @@
 #include "clar_libgit2.h"
 
 #include "odb.h"
-#include "fileops.h"
+#include "futils.h"
 #include "repository.h"
 
 #define TEMP_REPO_FOLDER "temprepo/"
@@ -33,12 +33,12 @@ static void ensure_repository_discover(const char *start_path,
        git_buf_attach(&resolved, p_realpath(expected_path, NULL), 0);
        cl_assert(resolved.size > 0);
        cl_git_pass(git_path_to_dir(&resolved));
-       cl_git_pass(git_repository_discover(&found_path, start_path, 0, ceiling_dirs));
+       cl_git_pass(git_repository_discover(&found_path, start_path, 1, ceiling_dirs));
 
        cl_assert_equal_s(found_path.ptr, resolved.ptr);
 
-       git_buf_free(&resolved);
-       git_buf_free(&found_path);
+       git_buf_dispose(&resolved);
+       git_buf_dispose(&found_path);
 }
 
 static void write_file(const char *path, const char *content)
@@ -58,7 +58,7 @@ static void write_file(const char *path, const char *content)
        cl_git_pass(error);
 }
 
-//no check is performed on ceiling_dirs length, so be sure it's long enough
+/*no check is performed on ceiling_dirs length, so be sure it's long enough */
 static void append_ceiling_dir(git_buf *ceiling_dirs, const char *path)
 {
        git_buf pretty_path = GIT_BUF_INIT;
@@ -71,7 +71,7 @@ static void append_ceiling_dir(git_buf *ceiling_dirs, const char *path)
 
        git_buf_puts(ceiling_dirs, pretty_path.ptr);
 
-       git_buf_free(&pretty_path);
+       git_buf_dispose(&pretty_path);
        cl_assert(git_buf_oom(ceiling_dirs) == 0);
 }
 
@@ -114,8 +114,8 @@ void test_repo_discover__initialize(void)
 
 void test_repo_discover__cleanup(void)
 {
-       git_buf_free(&discovered);
-       git_buf_free(&ceiling_dirs);
+       git_buf_dispose(&discovered);
+       git_buf_dispose(&ceiling_dirs);
        cl_git_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, NULL, GIT_RMDIR_REMOVE_FILES));
 }
 
@@ -199,3 +199,12 @@ void test_repo_discover__discovery_starting_at_file_succeeds(void)
 
        ensure_repository_discover(SUB_REPOSITORY_FOLDER "/file", ceiling_dirs.ptr, SUB_REPOSITORY_GITDIR);
 }
+
+void test_repo_discover__discovery_starting_at_system_root_causes_no_hang(void)
+{
+#ifdef GIT_WIN32
+       git_buf out = GIT_BUF_INIT;
+       cl_git_fail(git_repository_discover(&out, "C:/", 0, NULL));
+       cl_git_fail(git_repository_discover(&out, "//localhost/", 0, NULL));
+#endif
+}