mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-30 00:04:03 +00:00
Add failing test for issue 84
see https://github.com/libgit2/libgit2/issues#issue/84
This commit is contained in:
parent
ae6ba7f713
commit
677a3c07f4
@ -633,3 +633,34 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void posixify_path(char *path)
|
||||||
|
{
|
||||||
|
while (*path) {
|
||||||
|
if (*path == '\\')
|
||||||
|
*path = '/';
|
||||||
|
|
||||||
|
path++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int gitfo_getcwd(char *buffer_out, size_t size)
|
||||||
|
{
|
||||||
|
char *cwd_buffer;
|
||||||
|
|
||||||
|
assert(buffer_out && size > 0);
|
||||||
|
|
||||||
|
#ifdef GIT_WIN32
|
||||||
|
cwd_buffer = _getcwd(buffer_out, size);
|
||||||
|
#else
|
||||||
|
cwd_buffer = getcwd(buffer_out, size); //TODO: Fixme. Ensure the required headers are correctly included
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (cwd_buffer == NULL)
|
||||||
|
return GIT_EOSERR;
|
||||||
|
|
||||||
|
posixify_path(buffer_out);
|
||||||
|
|
||||||
|
git__joinpath(buffer_out, buffer_out, ""); //Ensure the path ends with a trailing slash
|
||||||
|
|
||||||
|
return GIT_SUCCESS;
|
||||||
|
}
|
||||||
|
@ -144,6 +144,8 @@ extern int gitfo_close_cached(gitfo_cache *ioc);
|
|||||||
extern int gitfo_cmp_path(const char *name1, int len1, int isdir1,
|
extern int gitfo_cmp_path(const char *name1, int len1, int isdir1,
|
||||||
const char *name2, int len2, int isdir2);
|
const char *name2, int len2, int isdir2);
|
||||||
|
|
||||||
|
extern int gitfo_getcwd(char *buffer_out, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up a provided absolute or relative directory path.
|
* Clean up a provided absolute or relative directory path.
|
||||||
*
|
*
|
||||||
|
@ -162,11 +162,33 @@ BEGIN_TEST(init1, "initialize a bare repo")
|
|||||||
must_pass(ensure_repository_init(TEMP_REPO_FOLDER_NS, BARE_REPOSITORY, NULL, path_repository, NULL));
|
must_pass(ensure_repository_init(TEMP_REPO_FOLDER_NS, BARE_REPOSITORY, NULL, path_repository, NULL));
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
BEGIN_TEST(init2, "Initialize a bare repo with a relative path escaping out of the current working directory")
|
||||||
|
char path_repository[GIT_PATH_MAX];
|
||||||
|
char current_workdir[GIT_PATH_MAX];
|
||||||
|
const int mode = 0755; /* or 0777 ? */
|
||||||
|
git_repository* repo;
|
||||||
|
|
||||||
|
must_pass(gitfo_getcwd(current_workdir, sizeof(current_workdir)));
|
||||||
|
|
||||||
|
git__joinpath(path_repository, current_workdir, "a/b/c/");
|
||||||
|
must_pass(gitfo_mkdir_recurs(path_repository, mode));
|
||||||
|
|
||||||
|
must_pass(chdir(path_repository));
|
||||||
|
|
||||||
|
must_pass(git_repository_init(&repo, "../d/e.git", 1));
|
||||||
|
git_repository_free(repo);
|
||||||
|
|
||||||
|
must_pass(chdir(current_workdir));
|
||||||
|
|
||||||
|
git__joinpath(path_repository, current_workdir, "a/");
|
||||||
|
must_pass(rmdir_recurs(path_repository));
|
||||||
|
END_TEST
|
||||||
|
|
||||||
BEGIN_SUITE(repository)
|
BEGIN_SUITE(repository)
|
||||||
ADD_TEST(odb0);
|
ADD_TEST(odb0);
|
||||||
ADD_TEST(odb1);
|
ADD_TEST(odb1);
|
||||||
ADD_TEST(init0);
|
ADD_TEST(init0);
|
||||||
ADD_TEST(init1);
|
ADD_TEST(init1);
|
||||||
|
ADD_TEST(init2);
|
||||||
END_SUITE
|
END_SUITE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user