mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-30 22:24:56 +00:00
Merge pull request #2124 from libgit2/better-shallow-errors
Improve error propagation in shallow call
This commit is contained in:
commit
2dc49ea93c
@ -2001,9 +2001,12 @@ int git_repository_is_shallow(git_repository *repo)
|
|||||||
error = git_path_lstat(path.ptr, &st);
|
error = git_path_lstat(path.ptr, &st);
|
||||||
git_buf_free(&path);
|
git_buf_free(&path);
|
||||||
|
|
||||||
if (error == GIT_ENOTFOUND)
|
if (error == GIT_ENOTFOUND) {
|
||||||
|
giterr_clear();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return -1;
|
return error;
|
||||||
return st.st_size == 0 ? 0 : 1;
|
return st.st_size == 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -31,3 +31,9 @@ void test_repo_shallow__shallow_repo(void)
|
|||||||
cl_assert_equal_i(1, git_repository_is_shallow(g_repo));
|
cl_assert_equal_i(1, git_repository_is_shallow(g_repo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_repo_shallow__clears_errors(void)
|
||||||
|
{
|
||||||
|
g_repo = cl_git_sandbox_init("testrepo.git");
|
||||||
|
cl_assert_equal_i(0, git_repository_is_shallow(g_repo));
|
||||||
|
cl_assert_equal_p(NULL, giterr_last());
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user