diff options
author | Russell Belfer <rb@github.com> | 2012-08-10 06:43:25 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-08-24 22:00:27 +0400 |
commit | 5f4a61aea834fe25ce1596bc9c0e0b5e563aa98b (patch) | |
tree | da0237ee649e009b5f914dfdace54d26e819aaaf /src/iterator.c | |
parent | 0c8858de8c82bae3fd88513724689a07d231da7e (diff) |
Working implementation of git_submodule_status
This is a big redesign of the git_submodule_status API and the
implementation of the redesigned API. It also fixes a number of
bugs that I found in other parts of the submodule API while
writing the tests for the status part.
This also fixes a couple of bugs in the iterators that had not
been noticed before - one with iterating when there is a gitlink
(i.e. separate-work-dir) and one where I was treating anything
even vaguely submodule-like as a submodule, more aggressively
than core git does.
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/iterator.c b/src/iterator.c index 819b0e22a..92fe67134 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -525,7 +525,9 @@ static int workdir_iterator__advance( while ((wf = wi->stack) != NULL) { next = git_vector_get(&wf->entries, ++wf->index); if (next != NULL) { - if (strcmp(next->path, DOT_GIT "/") == 0) + /* match git's behavior of ignoring anything named ".git" */ + if (strcmp(next->path, DOT_GIT "/") == 0 || + strcmp(next->path, DOT_GIT) == 0) continue; /* else found a good entry */ break; @@ -607,8 +609,8 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) wi->entry.path = ps->path; - /* skip over .git directory */ - if (strcmp(ps->path, DOT_GIT "/") == 0) + /* skip over .git entry */ + if (strcmp(ps->path, DOT_GIT "/") == 0 || strcmp(ps->path, DOT_GIT) == 0) return workdir_iterator__advance((git_iterator *)wi, NULL); /* if there is an error processing the entry, treat as ignored */ @@ -629,15 +631,10 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) /* detect submodules */ if (S_ISDIR(wi->entry.mode)) { - bool is_submodule = git_path_contains(&wi->path, DOT_GIT); - - /* if there is no .git, still check submodules data */ - if (!is_submodule) { - int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path); - is_submodule = (res == 0); - if (res == GIT_ENOTFOUND) - giterr_clear(); - } + int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path); + bool is_submodule = (res == 0); + if (res == GIT_ENOTFOUND) + giterr_clear(); /* if submodule, mark as GITLINK and remove trailing slash */ if (is_submodule) { |