#include "clar_libgit2.h"
#include "odb.h"
-#include "fileops.h"
+#include "futils.h"
#include "repository.h"
#define TEMP_REPO_FOLDER "temprepo/"
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)
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;
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);
}
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));
}
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
+}