From 277e304149011bb615ae258e25492350cbfd4d46 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 26 Mar 2012 11:22:27 -0700 Subject: [PATCH] Fix handling of submodules in trees --- src/tree.h | 2 +- tests-clar/status/submodules.c | 12 +++++------- tests/resources/submodules/.gitted/index | Bin 408 -> 408 bytes tests/resources/submodules/.gitted/logs/HEAD | Bin 167 -> 331 bytes .../submodules/.gitted/logs/refs/heads/master | Bin 167 -> 331 bytes .../97/896810b3210244a62a82458b8e0819ecfc6850 | Bin 0 -> 169 bytes .../b6/0fd986699ba4e9e68bea07cf8e793f323ef888 | Bin 0 -> 138 bytes .../submodules/.gitted/refs/heads/master | Bin 0 -> 41 bytes 8 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 tests/resources/submodules/.gitted/objects/97/896810b3210244a62a82458b8e0819ecfc6850 create mode 100644 tests/resources/submodules/.gitted/objects/b6/0fd986699ba4e9e68bea07cf8e793f323ef888 create mode 100644 tests/resources/submodules/.gitted/refs/heads/master 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 index b7400570e02979b65c61bb8099edeb7cf5fb02a2..97bf8ef515d84a4fcc16770b467f7afd6566c2b3 100644 GIT binary patch delta 82 zcmbQiJcD^cta$#j3I-tXhthlu3@i-c&(kNC9K<1YaFb$v%u0B4Hm_`0Ad| SY+NlQocO>eD0ymQ|9t=$1s44P diff --git a/tests/resources/submodules/.gitted/logs/HEAD b/tests/resources/submodules/.gitted/logs/HEAD index 193405c9f786b8aa37dec57e2df4b2a0bb6cc681..87a7bdafc28610696b807d15f38576dad610d89c 100644 GIT binary patch delta 97 zcmZ3^c$#U#@`;+78kXi3mSz@)21&+7h6Y9^CW&T7i55mCrWQ#SsRkB?mZ`~U$z~R& z1``7{w9PFH%qzE`%<&2yogVvQJszgJfw0Syjy^7R;46Snpy`ZoKr$HVVY2)Si>J zFFfcPQQP4}zEXmDJDa}bOW~eaenG|^5?_Ia*@|;@r z3CC?Ki^HMHQc`nLOHxx9IJJMzzF%^;=daQWAyJ{mce9p#kb)`!nv$88iA#-{0T3vZ sq!yPHr55BfEQ^2pdDiIk6;p);Z&&&6_}+X2|Fx~P-FVF^T_(jQ3>Y& literal 0 HcmV?d00001