diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-04-11 12:38:45 +0200 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-04-11 12:38:45 +0200 |
commit | dcfdb958e2033aa59beb624da4263ce031fbb21e (patch) | |
tree | f17365bd6314e8318d143a8f2e57659b31037519 /src/iterator.c | |
parent | 73fe6a8e20ffbc18ad667ff519c0fb8adf85fc3e (diff) | |
parent | efef3795a2d29f6b99bb9575585bb3fc19c3ed79 (diff) | |
download | libgit2-dcfdb958e2033aa59beb624da4263ce031fbb21e.tar.gz |
Merge branch 'new-error-handling' of github.com:libgit2/libgit2 into new-error-handling
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/iterator.c b/src/iterator.c index cc15b5f67..3a3be1755 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -9,6 +9,7 @@ #include "tree.h" #include "ignore.h" #include "buffer.h" +#include "git2/submodule.h" typedef struct tree_iterator_frame tree_iterator_frame; struct tree_iterator_frame { @@ -121,7 +122,6 @@ static int tree_iterator__advance( break; tree_iterator__pop_frame(ti); - git_buf_rtruncate_at_char(&ti->path, '/'); } if (te && entry_is_tree(te)) @@ -425,9 +425,25 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) return 0; /* if error, ignore it and ignore file */ /* detect submodules */ - if (S_ISDIR(wi->entry.mode) && - git_path_contains(&wi->path, DOT_GIT) == true) - wi->entry.mode = S_IFGITLINK; + 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(); + } + + /* if submodule, mark as GITLINK and remove trailing slash */ + if (is_submodule) { + size_t len = strlen(wi->entry.path); + assert(wi->entry.path[len - 1] == '/'); + wi->entry.path[len - 1] = '\0'; + wi->entry.mode = S_IFGITLINK; + } + } return 0; } @@ -485,7 +501,9 @@ int git_iterator_advance_into_directory( workdir_iterator *wi = (workdir_iterator *)iter; if (iter->type == GIT_ITERATOR_WORKDIR && - wi->entry.path && S_ISDIR(wi->entry.mode)) + wi->entry.path && + S_ISDIR(wi->entry.mode) && + !S_ISGITLINK(wi->entry.mode)) { if (workdir_iterator__expand_dir(wi) < 0) /* if error loading or if empty, skip the directory. */ |