mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-23 05:38:41 +00:00
Repository: A little fix in error code. GIT_ENOTFOUND is returned when a gitfile is malformed and GIT_ENOTAREPO when the pointed dir is not a repo.
Fixed tests so that it check the right error code.
This commit is contained in:
parent
5ec05d0748
commit
efcc87c9d9
@ -412,7 +412,7 @@ static int read_gitfile(char *path_out, size_t size, const char *file_path, cons
|
|||||||
for (;data[end_offset] == '\r' || data[end_offset] == '\n'; --end_offset);
|
for (;data[end_offset] == '\r' || data[end_offset] == '\n'; --end_offset);
|
||||||
data[end_offset + 1] = '\0';
|
data[end_offset + 1] = '\0';
|
||||||
|
|
||||||
if (GIT_FILE_CONTENT_PREFIX_LENGTH == end_offset) {
|
if (GIT_FILE_CONTENT_PREFIX_LENGTH == end_offset + 1) {
|
||||||
gitfo_free_buf(&file);
|
gitfo_free_buf(&file);
|
||||||
return git__throw(GIT_ENOTFOUND, "No path in git file `%s`", file_path);
|
return git__throw(GIT_ENOTFOUND, "No path in git file `%s`", file_path);
|
||||||
}
|
}
|
||||||
|
@ -345,15 +345,13 @@ BEGIN_TEST(discover0, "test discover")
|
|||||||
char repository_path[GIT_PATH_MAX];
|
char repository_path[GIT_PATH_MAX];
|
||||||
char sub_repository_path[GIT_PATH_MAX];
|
char sub_repository_path[GIT_PATH_MAX];
|
||||||
char found_path[GIT_PATH_MAX];
|
char found_path[GIT_PATH_MAX];
|
||||||
int error;
|
|
||||||
int mode = 0755;
|
int mode = 0755;
|
||||||
|
|
||||||
rmdir_recurs(DISCOVER_FOLDER);
|
rmdir_recurs(DISCOVER_FOLDER);
|
||||||
must_pass(append_ceiling_dir(ceiling_dirs,TEST_RESOURCES));
|
must_pass(append_ceiling_dir(ceiling_dirs,TEST_RESOURCES));
|
||||||
gitfo_mkdir_recurs(DISCOVER_FOLDER, mode);
|
gitfo_mkdir_recurs(DISCOVER_FOLDER, mode);
|
||||||
|
|
||||||
must_fail(error = git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
|
must_be_true(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
||||||
must_be_true(error == GIT_ENOTAREPO);
|
|
||||||
|
|
||||||
must_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
|
must_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
|
||||||
must_pass(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
|
must_pass(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
|
||||||
@ -387,15 +385,15 @@ BEGIN_TEST(discover0, "test discover")
|
|||||||
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
|
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
|
||||||
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
|
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
|
||||||
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
|
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
|
||||||
must_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
|
must_be_true(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
||||||
|
|
||||||
must_pass(append_ceiling_dir(ceiling_dirs, SUB_REPOSITORY_FOLDER));
|
must_pass(append_ceiling_dir(ceiling_dirs, SUB_REPOSITORY_FOLDER));
|
||||||
//this must pass as ceiling_directories cannot predent the current
|
//this must pass as ceiling_directories cannot predent the current
|
||||||
//working directory to be checked
|
//working directory to be checked
|
||||||
must_pass(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
|
must_pass(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
|
||||||
must_fail(error = git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
|
must_be_true(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
||||||
must_fail(error = git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
|
must_be_true(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
||||||
must_fail(error = git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
|
must_be_true(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs) == GIT_ENOTAREPO);
|
||||||
|
|
||||||
//.gitfile redirection should not be affected by ceiling directories
|
//.gitfile redirection should not be affected by ceiling directories
|
||||||
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
|
must_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
|
||||||
|
Loading…
Reference in New Issue
Block a user