Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rm: convert to use parse_pathspec
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 14 Jul 2013 08:35:42 +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/rm.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
817b345
)
diff --git
a/builtin/rm.c
b/builtin/rm.c
index 06025a2e751fbc2b2de3b024919c381cd2176c51..ee0ae4c396cb1eb5be4c12549ae7f8eefef097eb 100644
(file)
--- a/
builtin/rm.c
+++ b/
builtin/rm.c
@@
-11,6
+11,7
@@
#include "parse-options.h"
#include "string-list.h"
#include "submodule.h"
#include "parse-options.h"
#include "string-list.h"
#include "submodule.h"
+#include "pathspec.h"
static const char * const builtin_rm_usage[] = {
N_("git rm [options] [--] <file>..."),
static const char * const builtin_rm_usage[] = {
N_("git rm [options] [--] <file>..."),
@@
-279,7
+280,7
@@
static struct option builtin_rm_options[] = {
int cmd_rm(int argc, const char **argv, const char *prefix)
{
int i, newfd;
int cmd_rm(int argc, const char **argv, const char *prefix)
{
int i, newfd;
-
const char **
pathspec;
+
struct pathspec
pathspec;
char *seen;
git_config(git_default_config, NULL);
char *seen;
git_config(git_default_config, NULL);
@@
-312,31
+313,30
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
}
}
}
}
- pa
thspec = get_pathspec(
prefix, argv);
- refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
+ pa
rse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD,
prefix, argv);
+ refresh_index(&the_index, REFRESH_QUIET, pathspec
.raw
, NULL, NULL);
seen = NULL;
seen = NULL;
- for (i = 0; pathspec[i] ; i++)
- /* nothing */;
- seen = xcalloc(i, 1);
+ seen = xcalloc(pathspec.nr, 1);
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- if (!match_pathspec
(
pathspec, ce->name, ce_namelen(ce), 0, seen))
+ if (!match_pathspec
_depth(&
pathspec, ce->name, ce_namelen(ce), 0, seen))
continue;
ALLOC_GROW(list.entry, list.nr + 1, list.alloc);
list.entry[list.nr].name = ce->name;
list.entry[list.nr++].is_submodule = S_ISGITLINK(ce->ce_mode);
}
continue;
ALLOC_GROW(list.entry, list.nr + 1, list.alloc);
list.entry[list.nr].name = ce->name;
list.entry[list.nr++].is_submodule = S_ISGITLINK(ce->ce_mode);
}
- if (pathspec) {
- const char *
match
;
+ if (pathspec
.nr
) {
+ const char *
original
;
int seen_any = 0;
int seen_any = 0;
- for (i = 0; (match = pathspec[i]) != NULL ; i++) {
+ for (i = 0; i < pathspec.nr; i++) {
+ original = pathspec.items[i].original;
if (!seen[i]) {
if (!ignore_unmatch) {
die(_("pathspec '%s' did not match any files"),
if (!seen[i]) {
if (!ignore_unmatch) {
die(_("pathspec '%s' did not match any files"),
-
match
);
+
original
);
}
}
else {
}
}
else {
@@
-344,7
+344,7
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
}
if (!recursive && seen[i] == MATCHED_RECURSIVELY)
die(_("not removing '%s' recursively without -r"),
}
if (!recursive && seen[i] == MATCHED_RECURSIVELY)
die(_("not removing '%s' recursively without -r"),
- *
match ? match
: ".");
+ *
original ? original
: ".");
}
if (! seen_any)
}
if (! seen_any)