mv: move submodules using a gitfile
[gitweb.git] / builtin / checkout.c
index 6721de2ac867fe8b566ef0c6815fc870efb6ec98..7ea1100338cd79a40065700033b129d4031988d7 100644 (file)
@@ -83,12 +83,9 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
        return 0;
 }
 
-static int read_tree_some(struct tree *tree, const char **pathspec)
+static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
 {
-       struct pathspec ps;
-       init_pathspec(&ps, pathspec);
-       read_tree_recursive(tree, "", 0, 0, &ps, update_some, NULL);
-       free_pathspec(&ps);
+       read_tree_recursive(tree, "", 0, 0, pathspec, update_some, NULL);
 
        /* update the index with the given tree's info
         * for all args, expanding wildcards, and exit
@@ -257,16 +254,16 @@ static int checkout_paths(const struct checkout_opts *opts,
 
        if (opts->patch_mode)
                return run_add_interactive(revision, "--patch=checkout",
-                                          opts->pathspec.raw);
+                                          &opts->pathspec);
 
        lock_file = xcalloc(1, sizeof(struct lock_file));
 
        newfd = hold_locked_index(lock_file, 1);
-       if (read_cache_preload(opts->pathspec.raw) < 0)
+       if (read_cache_preload(&opts->pathspec) < 0)
                return error(_("corrupt index file"));
 
        if (opts->source_tree)
-               read_tree_some(opts->source_tree, opts->pathspec.raw);
+               read_tree_some(opts->source_tree, &opts->pathspec);
 
        ps_matched = xcalloc(1, opts->pathspec.nr);
 
@@ -307,7 +304,7 @@ static int checkout_paths(const struct checkout_opts *opts,
                        ce->ce_flags |= CE_MATCHED;
        }
 
-       if (report_path_error(ps_matched, opts->pathspec.raw, opts->prefix)) {
+       if (report_path_error(ps_matched, &opts->pathspec, opts->prefix)) {
                free(ps_matched);
                return 1;
        }
@@ -1159,10 +1156,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                 * cannot handle. Magic mask is pretty safe to be
                 * lifted for new magic when opts.patch_mode == 0.
                 */
-               parse_pathspec(&opts.pathspec,
-                              opts.patch_mode == 0 ? 0 :
-                              (PATHSPEC_ALL_MAGIC & ~PATHSPEC_FROMTOP),
-                              0, prefix, argv);
+               parse_pathspec(&opts.pathspec, 0,
+                              opts.patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0,
+                              prefix, argv);
 
                if (!opts.pathspec.nr)
                        die(_("invalid path specification"));