diff options
author | Vicent Martà <vicent@github.com> | 2013-05-24 01:14:52 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-05-24 01:14:52 -0700 |
commit | 4811c1500bfaaf8c7e61d712371f3ca429ef2016 (patch) | |
tree | 5c57bcc86f6ddba872c75c2866ef89594f22adc6 /src | |
parent | 30caf0cf2942412981b7662e50a2e9242afa2cce (diff) | |
parent | 6f0b8142e65b43f2224027a7abc67116ab6ad1a7 (diff) | |
download | libgit2-4811c1500bfaaf8c7e61d712371f3ca429ef2016.tar.gz |
Merge pull request #1603 from ben/shallow
Shallow-clone detection
Diffstat (limited to 'src')
-rw-r--r-- | src/repository.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/repository.c b/src/repository.c index 9957f32b7..28505e822 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1822,3 +1822,20 @@ int git_repository_state(git_repository *repo) git_buf_free(&repo_path); return state; } + +int git_repository_is_shallow(git_repository *repo) +{ + git_buf path = GIT_BUF_INIT; + struct stat st; + int error; + + git_buf_joinpath(&path, repo->path_repository, "shallow"); + error = git_path_lstat(path.ptr, &st); + git_buf_free(&path); + + if (error == GIT_ENOTFOUND) + return 0; + if (error < 0) + return -1; + return st.st_size == 0 ? 0 : 1; +} |