Fix up read_tree() pathspec matching to use "const char **"
authorLinus Torvalds <torvalds@g5.osdl.org>
Thu, 14 Jul 2005 18:39:27 +0000 (11:39 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 14 Jul 2005 18:39:27 +0000 (11:39 -0700)
The same way the other pathspecs work. Also fix missing success return
from the matching - not that anything actually uses this yet ;)

cache.h
tree.c
diff --git a/cache.h b/cache.h
index 53e3066fd70f92d75661d1f5bd8cbbd5697ae9c6..36cb4ae1f51678b088b7340aa470e029d5a47afe 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -191,7 +191,7 @@ extern char *write_sha1_file_prepare(void *buf,
 extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
 
 /* Read a tree into the cache */
-extern int read_tree(void *buffer, unsigned long size, int stage, char **paths);
+extern int read_tree(void *buffer, unsigned long size, int stage, const char **paths);
 
 extern int write_sha1_from_fd(const unsigned char *sha1, int fd);
 extern int write_sha1_to_fd(int fd, const unsigned char *sha1);
diff --git a/tree.c b/tree.c
index 8dc27e3b7354b8b8cc7d7491621929c78325a645..dabc2e7a2c6f51255914d49f854d82e42ddcab77 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -21,9 +21,9 @@ static int read_one_entry(unsigned char *sha1, const char *base, int baselen, co
        return add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
 }
 
-static int match_tree_entry(const char *base, int baselen, const char *path, unsigned int mode, char **paths)
+static int match_tree_entry(const char *base, int baselen, const char *path, unsigned int mode, const char **paths)
 {
-       char *match;
+       const char *match;
        int pathlen;
 
        if (!paths)
@@ -59,13 +59,15 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
 
                if (strncmp(path, match, pathlen))
                        continue;
+
+               return 1;
        }
        return 0;
 }
 
 static int read_tree_recursive(void *buffer, unsigned long size,
                               const char *base, int baselen,
-                              int stage, char **match)
+                              int stage, const char **match)
 {
        while (size) {
                int len = strlen(buffer)+1;
@@ -115,7 +117,7 @@ static int read_tree_recursive(void *buffer, unsigned long size,
        return 0;
 }
 
-int read_tree(void *buffer, unsigned long size, int stage, char **match)
+int read_tree(void *buffer, unsigned long size, int stage, const char **match)
 {
        return read_tree_recursive(buffer, size, "", 0, stage, match);
 }