Merge branch 'ts/doctar' into next
[gitweb.git] / update-index.c
index 7db67aacfedaa542b6f64175580ad5e4e4c15e8d..21448cc5cc3bfc13f2b21675e89f901d0d7067be 100644 (file)
@@ -245,70 +245,6 @@ static int refresh_cache(int really)
        return has_errors;
 }
 
-/*
- * We fundamentally don't like some paths: we don't want
- * dot or dot-dot anywhere, and for obvious reasons don't
- * want to recurse into ".git" either.
- *
- * Also, we don't want double slashes or slashes at the
- * end that can make pathnames ambiguous.
- */
-static int verify_dotfile(const char *rest)
-{
-       /*
-        * The first character was '.', but that
-        * has already been discarded, we now test
-        * the rest.
-        */
-       switch (*rest) {
-       /* "." is not allowed */
-       case '\0': case '/':
-               return 0;
-
-       /*
-        * ".git" followed by  NUL or slash is bad. This
-        * shares the path end test with the ".." case.
-        */
-       case 'g':
-               if (rest[1] != 'i')
-                       break;
-               if (rest[2] != 't')
-                       break;
-               rest += 2;
-       /* fallthrough */
-       case '.':
-               if (rest[1] == '\0' || rest[1] == '/')
-                       return 0;
-       }
-       return 1;
-}
-
-static int verify_path(const char *path)
-{
-       char c;
-
-       goto inside;
-       for (;;) {
-               if (!c)
-                       return 1;
-               if (c == '/') {
-inside:
-                       c = *path++;
-                       switch (c) {
-                       default:
-                               continue;
-                       case '/': case '\0':
-                               break;
-                       case '.':
-                               if (verify_dotfile(path))
-                                       continue;
-                       }
-                       return 0;
-               }
-               c = *path++;
-       }
-}
-
 static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
                         const char *path, int stage)
 {
@@ -393,7 +329,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
                die("Unable to process file %s", path);
        report("add '%s'", path);
  free_return:
-       if (p != path)
+       if (p < path || p > path + strlen(path))
                free((char*)p);
 }
 
@@ -609,7 +545,7 @@ static int do_unresolve(int ac, const char **av,
                const char *arg = av[i];
                const char *p = prefix_path(prefix, prefix_length, arg);
                err |= unresolve_one(p);
-               if (p != arg)
+               if (p < arg || p > arg + strlen(arg))
                        free((char*)p);
        }
        return err;
@@ -623,7 +559,7 @@ static int do_reupdate(int ac, const char **av,
         */
        int pos;
        int has_head = 1;
-       char **pathspec = get_pathspec(prefix, av + 1);
+       const char **pathspec = get_pathspec(prefix, av + 1);
 
        if (read_ref(git_path("HEAD"), head_sha1))
                /* If there is no HEAD, that means it is an initial
@@ -815,7 +751,7 @@ int main(int argc, const char **argv)
                        update_one(p, NULL, 0);
                        if (set_executable_bit)
                                chmod_path(set_executable_bit, p);
-                       if (p != path_name)
+                       if (p < path_name || p > path_name + strlen(path_name))
                                free((char*) p);
                        if (path_name != buf.buf)
                                free(path_name);