Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
ls-files: convert to use parse_pathspec
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 14 Jul 2013 08:35:43 +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/ls-files.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
29211a9
)
diff --git
a/builtin/ls-files.c
b/builtin/ls-files.c
index 30357dfd55a3a64ebd9d40b67930df92e5c4122b..f1be425129d4e76a5df10527a67f5d3a87cff2ec 100644
(file)
--- a/
builtin/ls-files.c
+++ b/
builtin/ls-files.c
@@
-31,7
+31,7
@@
static int debug_mode;
static const char *prefix;
static int max_prefix_len;
static int prefix_len;
static const char *prefix;
static int max_prefix_len;
static int prefix_len;
-static
const char **
pathspec;
+static
struct pathspec
pathspec;
static int error_unmatch;
static char *ps_matched;
static const char *with_tree;
static int error_unmatch;
static char *ps_matched;
static const char *with_tree;
@@
-60,7
+60,7
@@
static void show_dir_entry(const char *tag, struct dir_entry *ent)
if (len >= ent->len)
die("git ls-files: internal error - directory entry not superset of prefix");
if (len >= ent->len)
die("git ls-files: internal error - directory entry not superset of prefix");
- if (!match_pathspec
(
pathspec, ent->name, ent->len, len, ps_matched))
+ if (!match_pathspec
_depth(&
pathspec, ent->name, ent->len, len, ps_matched))
return;
fputs(tag, stdout);
return;
fputs(tag, stdout);
@@
-135,7
+135,7
@@
static void show_ce_entry(const char *tag, struct cache_entry *ce)
if (len >= ce_namelen(ce))
die("git ls-files: internal error - cache entry not superset of prefix");
if (len >= ce_namelen(ce))
die("git ls-files: internal error - cache entry not superset of prefix");
- if (!match_pathspec
(
pathspec, ce->name, ce_namelen(ce), len, ps_matched))
+ if (!match_pathspec
_depth(&
pathspec, ce->name, ce_namelen(ce), len, ps_matched))
return;
if (tag && *tag && show_valid_bit &&
return;
if (tag && *tag && show_valid_bit &&
@@
-191,7
+191,7
@@
static void show_ru_info(void)
len = strlen(path);
if (len < max_prefix_len)
continue; /* outside of the prefix */
len = strlen(path);
if (len < max_prefix_len)
continue; /* outside of the prefix */
- if (!match_pathspec
(
pathspec, path, len, max_prefix_len, ps_matched))
+ if (!match_pathspec
_depth(&
pathspec, path, len, max_prefix_len, ps_matched))
continue; /* uninterested */
for (i = 0; i < 3; i++) {
if (!ui->mode[i])
continue; /* uninterested */
for (i = 0; i < 3; i++) {
if (!ui->mode[i])
@@
-216,7
+216,7
@@
static void show_files(struct dir_struct *dir)
/* For cached/deleted files we don't need to even do the readdir */
if (show_others || show_killed) {
/* For cached/deleted files we don't need to even do the readdir */
if (show_others || show_killed) {
- fill_directory(dir, pathspec);
+ fill_directory(dir, pathspec
.raw
);
if (show_others)
show_other_files(dir);
if (show_killed)
if (show_others)
show_other_files(dir);
if (show_killed)
@@
-284,21
+284,6
@@
static void prune_cache(const char *prefix)
active_nr = last;
}
active_nr = last;
}
-static void strip_trailing_slash_from_submodules(void)
-{
- const char **p;
-
- for (p = pathspec; *p != NULL; p++) {
- int len = strlen(*p), pos;
-
- if (len < 1 || (*p)[len - 1] != '/')
- continue;
- pos = cache_name_pos(*p, len - 1);
- if (pos >= 0 && S_ISGITLINK(active_cache[pos]->ce_mode))
- *p = xstrndup(*p, len - 1);
- }
-}
-
/*
* Read the tree specified with --with-tree option
* (typically, HEAD) into stage #1 and then
/*
* Read the tree specified with --with-tree option
* (typically, HEAD) into stage #1 and then
@@
-552,23
+537,18
@@
int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
- pathspec = get_pathspec(prefix, argv);
-
- /* be nice with submodule paths ending in a slash */
- if (pathspec)
- strip_trailing_slash_from_submodules();
+ parse_pathspec(&pathspec, 0,
+ PATHSPEC_PREFER_CWD |
+ PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ prefix, argv);
/* Find common prefix for all pathspec's */
/* Find common prefix for all pathspec's */
- max_prefix = common_prefix(pathspec);
+ max_prefix = common_prefix(pathspec
.raw
);
max_prefix_len = max_prefix ? strlen(max_prefix) : 0;
/* Treat unmatching pathspec elements as errors */
max_prefix_len = max_prefix ? strlen(max_prefix) : 0;
/* Treat unmatching pathspec elements as errors */
- if (pathspec && error_unmatch) {
- int num;
- for (num = 0; pathspec[num]; num++)
- ;
- ps_matched = xcalloc(1, num);
- }
+ if (pathspec.nr && error_unmatch)
+ ps_matched = xcalloc(1, pathspec.nr);
if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
die("ls-files --ignored needs some exclude pattern");
if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
die("ls-files --ignored needs some exclude pattern");
@@
-595,7
+575,7
@@
int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (ps_matched) {
int bad;
if (ps_matched) {
int bad;
- bad = report_path_error(ps_matched, pathspec, prefix);
+ bad = report_path_error(ps_matched, pathspec
.raw
, prefix);
if (bad)
fprintf(stderr, "Did you forget to 'git add'?\n");
if (bad)
fprintf(stderr, "Did you forget to 'git add'?\n");