mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 17:05:49 +00:00
Merge pull request #1562 from libgit2/cmn/refs-namespace-lookup
Provide the user with a more useful error code when a looking up a reference which name points to a namepace
This commit is contained in:
commit
2c2b0ebb4a
@ -147,7 +147,13 @@ int git_futils_readbuffer_updated(
|
|||||||
if (p_stat(path, &st) < 0)
|
if (p_stat(path, &st) < 0)
|
||||||
return git_path_set_error(errno, path, "stat");
|
return git_path_set_error(errno, path, "stat");
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode) || !git__is_sizet(st.st_size+1)) {
|
|
||||||
|
if (S_ISDIR(st.st_mode)) {
|
||||||
|
giterr_set(GITERR_INVALID, "requested file is a directory");
|
||||||
|
return GIT_ENOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!git__is_sizet(st.st_size+1)) {
|
||||||
giterr_set(GITERR_OS, "Invalid regular file stat for '%s'", path);
|
giterr_set(GITERR_OS, "Invalid regular file stat for '%s'", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -46,3 +46,15 @@ void test_refs_lookup__oid(void)
|
|||||||
cl_git_pass(git_oid_fromstr(&expected, "1385f264afb75a56a5bec74243be9b367ba4ca08"));
|
cl_git_pass(git_oid_fromstr(&expected, "1385f264afb75a56a5bec74243be9b367ba4ca08"));
|
||||||
cl_assert(git_oid_cmp(&tag, &expected) == 0);
|
cl_assert(git_oid_cmp(&tag, &expected) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_refs_lookup__namespace(void)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
git_reference *ref;
|
||||||
|
|
||||||
|
error = git_reference_lookup(&ref, g_repo, "refs/heads");
|
||||||
|
cl_assert_equal_i(error, GIT_ENOTFOUND);
|
||||||
|
|
||||||
|
error = git_reference_lookup(&ref, g_repo, "refs/heads/");
|
||||||
|
cl_assert_equal_i(error, GIT_EINVALIDSPEC);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user