Merge branch 'jc/reupdate' into next
authorJunio C Hamano <junkio@cox.net>
Sun, 7 May 2006 04:47:07 +0000 (21:47 -0700)
committerJunio C Hamano <junkio@cox.net>
Sun, 7 May 2006 04:47:07 +0000 (21:47 -0700)
* jc/reupdate:
Fix users of prefix_path() to free() only when necessary

checkout-index.c
update-index.c
index 64bdc3bd132288f9c130488446214b125d2cfb14..9876af6fd60a81d871e6be30060cc93d0e0259c7 100644 (file)
@@ -278,7 +278,7 @@ int main(int argc, char **argv)
                        die("git-checkout-index: don't mix '--stdin' and explicit filenames");
                p = prefix_path(prefix, prefix_length, arg);
                checkout_file(p);
-               if (p != arg)
+               if (p < arg || p > arg + strlen(arg))
                        free((char*)p);
        }
 
@@ -300,7 +300,7 @@ int main(int argc, char **argv)
                                path_name = buf.buf;
                        p = prefix_path(prefix, prefix_length, path_name);
                        checkout_file(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);
index 7db67aacfedaa542b6f64175580ad5e4e4c15e8d..f6b09a4800b01f3c1675e87a91ea458e7172f169 100644 (file)
@@ -393,7 +393,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 +609,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 +623,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 +815,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);