Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
checkout: convert to use parse_pathspec
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 14 Jul 2013 08:35:41 +0000
(15:35 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 15 Jul 2013 17:56:07 +0000
(10:56 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
01a10b0
)
diff --git
a/builtin/checkout.c
b/builtin/checkout.c
index 7fe0bffaf8b875b40b5e4e0e5c207f978c932691..6721de2ac867fe8b566ef0c6815fc870efb6ec98 100644
(file)
--- a/
builtin/checkout.c
+++ b/
builtin/checkout.c
@@
-46,7
+46,7
@@
struct checkout_opts {
int branch_exists;
const char *prefix;
int branch_exists;
const char *prefix;
-
const char **
pathspec;
+
struct pathspec
pathspec;
struct tree *source_tree;
};
struct tree *source_tree;
};
@@
-257,20
+257,18
@@
static int checkout_paths(const struct checkout_opts *opts,
if (opts->patch_mode)
return run_add_interactive(revision, "--patch=checkout",
if (opts->patch_mode)
return run_add_interactive(revision, "--patch=checkout",
- opts->pathspec);
+ opts->pathspec
.raw
);
lock_file = xcalloc(1, sizeof(struct lock_file));
newfd = hold_locked_index(lock_file, 1);
lock_file = xcalloc(1, sizeof(struct lock_file));
newfd = hold_locked_index(lock_file, 1);
- if (read_cache_preload(opts->pathspec) < 0)
+ if (read_cache_preload(opts->pathspec
.raw
) < 0)
return error(_("corrupt index file"));
if (opts->source_tree)
return error(_("corrupt index file"));
if (opts->source_tree)
- read_tree_some(opts->source_tree, opts->pathspec);
+ read_tree_some(opts->source_tree, opts->pathspec
.raw
);
- for (pos = 0; opts->pathspec[pos]; pos++)
- ;
- ps_matched = xcalloc(1, pos);
+ ps_matched = xcalloc(1, opts->pathspec.nr);
/*
* Make sure all pathspecs participated in locating the paths
/*
* Make sure all pathspecs participated in locating the paths
@@
-304,12
+302,12
@@
static int checkout_paths(const struct checkout_opts *opts,
* match_pathspec() for _all_ entries when
* opts->source_tree != NULL.
*/
* match_pathspec() for _all_ entries when
* opts->source_tree != NULL.
*/
- if (match_pathspec
(
opts->pathspec, ce->name, ce_namelen(ce),
+ if (match_pathspec
_depth(&
opts->pathspec, ce->name, ce_namelen(ce),
0, ps_matched))
ce->ce_flags |= CE_MATCHED;
}
0, ps_matched))
ce->ce_flags |= CE_MATCHED;
}
- if (report_path_error(ps_matched, opts->pathspec, opts->prefix)) {
+ if (report_path_error(ps_matched, opts->pathspec
.raw
, opts->prefix)) {
free(ps_matched);
return 1;
}
free(ps_matched);
return 1;
}
@@
-1002,7
+1000,7
@@
static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new)
{
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new)
{
- if (opts->pathspec)
+ if (opts->pathspec
.nr
)
die(_("paths cannot be used with switching branches"));
if (opts->patch_mode)
die(_("paths cannot be used with switching branches"));
if (opts->patch_mode)
@@
-1154,9
+1152,19
@@
int cmd_checkout(int argc, const char **argv, const char *prefix)
}
if (argc) {
}
if (argc) {
- opts.pathspec = get_pathspec(prefix, argv);
+ /*
+ * In patch mode (opts.patch_mode != 0), we pass the
+ * pathspec to an external program, git-add--interactive.
+ * Do not accept any kind of magic that that program
+ * 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);
- if (!opts.pathspec)
+ if (!opts.pathspec
.nr
)
die(_("invalid path specification"));
/*
die(_("invalid path specification"));
/*
@@
-1188,7
+1196,7
@@
int cmd_checkout(int argc, const char **argv, const char *prefix)
strbuf_release(&buf);
}
strbuf_release(&buf);
}
- if (opts.patch_mode || opts.pathspec)
+ if (opts.patch_mode || opts.pathspec
.nr
)
return checkout_paths(&opts, new.name);
else
return checkout_branch(&opts, &new);
return checkout_paths(&opts, new.name);
else
return checkout_branch(&opts, &new);