diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-03-26 11:22:27 -0700 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-03-26 11:22:27 -0700 |
| commit | 277e304149011bb615ae258e25492350cbfd4d46 (patch) | |
| tree | 45d51890224f8a661a15500a4831e77d0068f144 | |
| parent | 1db12b00532d747fa7a805a8fa8d293c58ec16d9 (diff) | |
| download | libgit2-277e304149011bb615ae258e25492350cbfd4d46.tar.gz | |
Fix handling of submodules in trees
| -rw-r--r-- | src/tree.h | 2 | ||||
| -rw-r--r-- | tests-clar/status/submodules.c | 12 | ||||
| -rw-r--r-- | tests/resources/submodules/.gitted/index | bin | 408 -> 408 bytes | |||
| -rw-r--r-- | tests/resources/submodules/.gitted/logs/HEAD | 1 | ||||
| -rw-r--r-- | tests/resources/submodules/.gitted/logs/refs/heads/master | 1 | ||||
| -rw-r--r-- | tests/resources/submodules/.gitted/objects/97/896810b3210244a62a82458b8e0819ecfc6850 | 3 | ||||
| -rw-r--r-- | tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888 | bin | 0 -> 138 bytes | |||
| -rw-r--r-- | tests/resources/submodules/.gitted/refs/heads/master | 1 |
8 files changed, 12 insertions, 8 deletions
diff --git a/src/tree.h b/src/tree.h index 0bff41312..fd00afde5 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 ca6c2ef30..9fd4f0d5f 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 Binary files differindex b7400570e..97bf8ef51 100644 --- a/tests/resources/submodules/.gitted/index +++ b/tests/resources/submodules/.gitted/index diff --git a/tests/resources/submodules/.gitted/logs/HEAD b/tests/resources/submodules/.gitted/logs/HEAD index 193405c9f..87a7bdafc 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 193405c9f..87a7bdafc 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 000000000..1c8dbdf9f --- /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 Binary files differnew file mode 100644 index 000000000..3d78bd6be --- /dev/null +++ b/tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888 diff --git a/tests/resources/submodules/.gitted/refs/heads/master b/tests/resources/submodules/.gitted/refs/heads/master new file mode 100644 index 000000000..32b935853 --- /dev/null +++ b/tests/resources/submodules/.gitted/refs/heads/master @@ -0,0 +1 @@ +97896810b3210244a62a82458b8e0819ecfc6850 |
