summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-01-10 12:28:38 -0800
committerJunio C Hamano <gitster@pobox.com>2012-01-10 12:28:38 -0800
commitc432ef996e28a2f02369c505b841f86ec30c85fb (patch)
tree48284086b2b78dac67657b935f3070ec3a836716
parent909ca7b9ac11711478aaa5dd4ab17a0d1dabe075 (diff)
downloadgit-c432ef996e28a2f02369c505b841f86ec30c85fb.tar.gz
attr.c: clarify the logic to pop attr_stack
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--attr.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/attr.c b/attr.c
index a6e6523d29..2ce7365138 100644
--- a/attr.c
+++ b/attr.c
@@ -567,7 +567,9 @@ static void prepare_attr_stack(const char *path, int dirlen)
/*
* Pop the ones from directories that are not the prefix of
- * the path we are checking.
+ * the path we are checking. Break out of the loop when we see
+ * the root one (whose origin is an empty string "") or the builtin
+ * one (whose origin is NULL) without popping it.
*/
while (attr_stack->origin) {
int namelen = strlen(attr_stack->origin);
@@ -587,6 +589,13 @@ static void prepare_attr_stack(const char *path, int dirlen)
* Read from parent directories and push them down
*/
if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
+ /*
+ * bootstrap_attr_stack() should have added, and the
+ * above loop should have stopped before popping, the
+ * root element whose attr_stack->origin is set to an
+ * empty string.
+ */
+ assert(attr_stack->origin);
while (1) {
char *cp;