Fix handling of submodules in trees
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
diff --git a/src/tree.h b/src/tree.h
index 0bff413..fd00afd 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -32,7 +32,7 @@ struct git_treebuilder {
GIT_INLINE(unsigned int) entry_is_tree(const struct git_tree_entry *e)
{
- return e->attr & 040000;
+ return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
}
void git_tree__free(git_tree *tree);
diff --git a/tests-clar/status/submodules.c b/tests-clar/status/submodules.c
index ca6c2ef..9fd4f0d 100644
--- a/tests-clar/status/submodules.c
+++ b/tests-clar/status/submodules.c
@@ -29,7 +29,7 @@ void test_status_submodules__cleanup(void)
}
static int
-cb_status__count(const char *p, unsigned int s, void *payload)
+cb_status__submodule_count(const char *p, unsigned int s, void *payload)
{
volatile int *count = (int *)payload;
@@ -50,10 +50,10 @@ void test_status_submodules__0(void)
cl_assert(git_path_isfile("submodules/.gitmodules"));
cl_git_pass(
- git_status_foreach(g_repo, cb_status__count, &counts)
+ git_status_foreach(g_repo, cb_status__submodule_count, &counts)
);
- cl_assert(counts == 7);
+ cl_assert(counts == 6);
}
static const char *expected_files[] = {
@@ -62,17 +62,15 @@ static const char *expected_files[] = {
"deleted",
"ignored",
"modified",
- "testrepo",
"untracked"
};
static unsigned int expected_status[] = {
- GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_MODIFIED,
+ GIT_STATUS_WT_MODIFIED,
GIT_STATUS_INDEX_NEW,
GIT_STATUS_INDEX_DELETED,
GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED,
- GIT_STATUS_INDEX_NEW, /* submodule added in index, but not committed */
GIT_STATUS_WT_NEW
};
@@ -100,5 +98,5 @@ void test_status_submodules__1(void)
git_status_foreach(g_repo, cb_status__match, &index)
);
- cl_assert(index == 7);
+ cl_assert(index == 6);
}
diff --git a/tests/resources/submodules/.gitted/index b/tests/resources/submodules/.gitted/index
index b740057..97bf8ef 100644
Binary files a/tests/resources/submodules/.gitted/index and b/tests/resources/submodules/.gitted/index differ
diff --git a/tests/resources/submodules/.gitted/logs/HEAD b/tests/resources/submodules/.gitted/logs/HEAD
index 193405c..87a7bda 100644
--- a/tests/resources/submodules/.gitted/logs/HEAD
+++ b/tests/resources/submodules/.gitted/logs/HEAD
@@ -1 +1,2 @@
0000000000000000000000000000000000000000 09176a980273d801a3e37cc45c84af1366501ed9 Russell Belfer <arrbee@arrbee.com> 1332365253 -0700 commit (initial): initial commit
+09176a980273d801a3e37cc45c84af1366501ed9 97896810b3210244a62a82458b8e0819ecfc6850 Russell Belfer <arrbee@arrbee.com> 1332780781 -0700 commit: Setting up gitmodules
diff --git a/tests/resources/submodules/.gitted/logs/refs/heads/master b/tests/resources/submodules/.gitted/logs/refs/heads/master
index 193405c..87a7bda 100644
--- a/tests/resources/submodules/.gitted/logs/refs/heads/master
+++ b/tests/resources/submodules/.gitted/logs/refs/heads/master
@@ -1 +1,2 @@
0000000000000000000000000000000000000000 09176a980273d801a3e37cc45c84af1366501ed9 Russell Belfer <arrbee@arrbee.com> 1332365253 -0700 commit (initial): initial commit
+09176a980273d801a3e37cc45c84af1366501ed9 97896810b3210244a62a82458b8e0819ecfc6850 Russell Belfer <arrbee@arrbee.com> 1332780781 -0700 commit: Setting up gitmodules
diff --git a/tests/resources/submodules/.gitted/objects/97/896810b3210244a62a82458b8e0819ecfc6850 b/tests/resources/submodules/.gitted/objects/97/896810b3210244a62a82458b8e0819ecfc6850
new file mode 100644
index 0000000..1c8dbdf
--- /dev/null
+++ b/tests/resources/submodules/.gitted/objects/97/896810b3210244a62a82458b8e0819ecfc6850
@@ -0,0 +1,3 @@
+x[
+0E*fʤS K4ݿwׅ9p2MCFP@u..p!OYdiYU'̕8XbPn6
+ħԞ1[q}0qc[W#1fR:SZ+Y+{tdlvOmu_}5i` K
\ No newline at end of file
diff --git a/tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888 b/tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888
new file mode 100644
index 0000000..3d78bd6
Binary files /dev/null and b/tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888 differ
diff --git a/tests/resources/submodules/.gitted/refs/heads/master b/tests/resources/submodules/.gitted/refs/heads/master
new file mode 100644
index 0000000..32b9358
--- /dev/null
+++ b/tests/resources/submodules/.gitted/refs/heads/master
@@ -0,0 +1 @@
+97896810b3210244a62a82458b8e0819ecfc6850