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
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-07-24 23:04:20 +0300
committerEdward Thomson <ethomson@edwardthomson.com>2015-07-24 23:04:20 +0300
commit759b2230a522df47640808cb0b21346cc824f6ff (patch)
tree2b91eae8b3536ddc2ed6c6b88ae175a92fcdc094 /tests
parent91dad181439e0ea59bb84f8af9d7e144646f20c1 (diff)
parent247d27c2c6868e808191e6090056ecece6da30c4 (diff)
Merge pull request #3303 from libgit2/cmn/index-add-submodule
Allow adding a submodule through git_index_add_bypath
Diffstat (limited to 'tests')
-rw-r--r--tests/index/bypath.c35
-rw-r--r--tests/submodule/add.c1
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/index/bypath.c b/tests/index/bypath.c
new file mode 100644
index 000000000..ddb766a22
--- /dev/null
+++ b/tests/index/bypath.c
@@ -0,0 +1,35 @@
+#include "clar_libgit2.h"
+#include "repository.h"
+#include "../submodule/submodule_helpers.h"
+
+static git_repository *g_repo;
+static git_index *g_idx;
+
+void test_index_bypath__initialize(void)
+{
+ g_repo = setup_fixture_submod2();
+ cl_git_pass(git_repository_index__weakptr(&g_idx, g_repo));
+}
+
+void test_index_bypath__cleanup(void)
+{
+ g_repo = NULL;
+ g_idx = NULL;
+}
+
+void test_index_bypath__add_directory(void)
+{
+ cl_git_fail_with(GIT_EDIRECTORY, git_index_add_bypath(g_idx, "just_a_dir"));
+}
+
+void test_index_bypath__add_submodule(void)
+{
+ unsigned int status;
+ const char *sm_name = "sm_changed_head";
+
+ cl_git_pass(git_submodule_status(&status, g_repo, sm_name, 0));
+ cl_assert_equal_i(GIT_SUBMODULE_STATUS_WD_MODIFIED, status & GIT_SUBMODULE_STATUS_WD_MODIFIED);
+ cl_git_pass(git_index_add_bypath(g_idx, sm_name));
+ cl_git_pass(git_submodule_status(&status, g_repo, sm_name, 0));
+ cl_assert_equal_i(0, status & GIT_SUBMODULE_STATUS_WD_MODIFIED);
+}
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index 01625d3aa..c3b3e6364 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -4,6 +4,7 @@
#include "submodule_helpers.h"
#include "config/config_helpers.h"
#include "fileops.h"
+#include "repository.h"
static git_repository *g_repo = NULL;