diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-06 16:16:46 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-07 08:33:27 +0100 |
commit | 62a617dc683c1e73eebd0e1b6209f76748e67ed4 (patch) | |
tree | 5893fe2b801d96825582d8a461b50e80f4a2a43a /tests/submodule | |
parent | f1a7906fdf0657fba88449bdab07237847f36670 (diff) | |
download | libgit2-cmn/submodule-and-dir.tar.gz |
iterator: submodules are determined by an index or treecmn/submodule-and-dir
We cannot know from looking at .gitmodules whether a directory is a
submodule or not. We need the index or tree we are comparing against to
tell us. Otherwise we have to assume the entry in .gitmodules is stale
or otherwise invalid.
Thus we pass the index of the repository into the workdir iterator, even
if we do not want to compare against it. This follows what git does,
which even for `git diff <tree>`, it will consider staged submodules as
such.
Diffstat (limited to 'tests/submodule')
-rw-r--r-- | tests/submodule/status.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/submodule/status.c b/tests/submodule/status.c index 6473491b9..6efae35c6 100644 --- a/tests/submodule/status.c +++ b/tests/submodule/status.c @@ -317,14 +317,17 @@ void test_submodule_status__iterator(void) }; submodule_expectations exp = { 0, expected, expected_flags }; git_status_options opts = GIT_STATUS_OPTIONS_INIT; + git_index *index; - cl_git_pass(git_iterator_for_workdir(&iter, g_repo, + cl_git_pass(git_repository_index(&index, g_repo)); + cl_git_pass(git_iterator_for_workdir(&iter, g_repo, index, NULL, GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_INCLUDE_TREES, NULL, NULL)); for (i = 0; !git_iterator_advance(&entry, iter); ++i) cl_assert_equal_s(expected[i], entry->path); git_iterator_free(iter); + git_index_free(index); opts.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_INCLUDE_UNMODIFIED | |