Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-05-18 01:21:10 +0400
committerRussell Belfer <rb@github.com>2012-05-18 01:21:10 +0400
commit6e5c4af00eb2765dc2a093d8aa3cffed5b627ab9 (patch)
tree4908a6a4f51d14acd91487b885c968307f1f1af3 /src/iterator.c
parentdb756d5898fa6e0bdd2aeaa2cccfa55ece6c09a2 (diff)
Fix workdir iterators on empty directories
Creating a workdir iterator on a directory with absolutely no files was returning an error (GIT_ENOTFOUND) instead of an iterator for nothing. This fixes that and includes two new tests that cover that case.
Diffstat (limited to 'src/iterator.c')
-rw-r--r--src/iterator.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/iterator.c b/src/iterator.c
index 40ef01618..819b0e22a 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -660,6 +660,8 @@ int git_iterator_for_workdir_range(
int error;
workdir_iterator *wi;
+ assert(iter && repo);
+
if (git_repository_is_bare(repo)) {
giterr_set(GITERR_INVALID,
"Cannot scan working directory for bare repo");
@@ -680,10 +682,16 @@ int git_iterator_for_workdir_range(
wi->root_len = wi->path.size;
- if ((error = workdir_iterator__expand_dir(wi)) < 0)
- git_iterator_free((git_iterator *)wi);
- else
- *iter = (git_iterator *)wi;
+ if ((error = workdir_iterator__expand_dir(wi)) < 0) {
+ if (error == GIT_ENOTFOUND)
+ error = 0;
+ else {
+ git_iterator_free((git_iterator *)wi);
+ wi = NULL;
+ }
+ }
+
+ *iter = (git_iterator *)wi;
return error;
}