From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 18/21] Convert {read,fill}_directory to take struct pathspec
Date: Fri, 11 Jan 2013 18:21:12 +0700 [thread overview]
Message-ID: <1357903275-16804-19-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/add.c | 2 +-
builtin/clean.c | 2 +-
builtin/grep.c | 2 +-
builtin/ls-files.c | 2 +-
dir.c | 10 +++++-----
dir.h | 4 ++--
wt-status.c | 4 ++--
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 4e2b603..0295cef 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -402,7 +402,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
}
/* This picks up the paths that are not tracked */
- baselen = fill_directory(&dir, pathspec.raw);
+ baselen = fill_directory(&dir, &pathspec);
if (pathspec.nr)
seen = prune_directory(&dir, pathspec.raw, baselen);
}
diff --git a/builtin/clean.c b/builtin/clean.c
index 788ad8c..41c8cad 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -103,7 +103,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
parse_pathspec(&pathspec, PATHSPEC_FROMTOP, 0, prefix, argv);
- fill_directory(&dir, pathspec.raw);
+ fill_directory(&dir, &pathspec);
if (pathspec.nr)
seen = xmalloc(pathspec.nr);
diff --git a/builtin/grep.c b/builtin/grep.c
index 705f9ff..f370bad 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -522,7 +522,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,
if (exc_std)
setup_standard_excludes(&dir);
- fill_directory(&dir, pathspec->raw);
+ fill_directory(&dir, pathspec);
for (i = 0; i < dir.nr; i++) {
const char *name = dir.entries[i]->name;
int namelen = strlen(name);
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index be6e05d..7bb637b 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -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) {
- fill_directory(dir, pathspec.raw);
+ fill_directory(dir, &pathspec);
if (show_others)
show_other_files(dir);
if (show_killed)
diff --git a/dir.c b/dir.c
index 4d1f71c..eb52913 100644
--- a/dir.c
+++ b/dir.c
@@ -72,7 +72,7 @@ char *common_prefix(const char **pathspec)
return len ? xmemdupz(*pathspec, len) : NULL;
}
-int fill_directory(struct dir_struct *dir, const char **pathspec)
+int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
{
size_t len;
@@ -80,10 +80,10 @@ int fill_directory(struct dir_struct *dir, const char **pathspec)
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk
*/
- len = common_prefix_len(pathspec);
+ len = common_prefix_len(pathspec->raw);
/* Read the directory and prune it */
- read_directory(dir, pathspec ? *pathspec : "", len, pathspec);
+ read_directory(dir, pathspec->nr ? pathspec->raw[0] : "", len, pathspec);
return len;
}
@@ -1211,14 +1211,14 @@ static int treat_leading_path(struct dir_struct *dir,
return rc;
}
-int read_directory(struct dir_struct *dir, const char *path, int len, const char **pathspec)
+int read_directory(struct dir_struct *dir, const char *path, int len, const struct pathspec *pathspec)
{
struct path_simplify *simplify;
if (has_symlink_leading_path(path, len))
return dir->nr;
- simplify = create_simplify(pathspec);
+ simplify = create_simplify(pathspec ? pathspec->raw : NULL);
if (!len || treat_leading_path(dir, path, len, simplify))
read_directory_recursive(dir, path, len, 0, simplify);
free_simplify(simplify);
diff --git a/dir.h b/dir.h
index 1d4888b..b51d2e9 100644
--- a/dir.h
+++ b/dir.h
@@ -74,8 +74,8 @@ extern int match_pathspec_depth(const struct pathspec *pathspec,
int prefix, char *seen);
extern int within_depth(const char *name, int namelen, int depth, int max_depth);
-extern int fill_directory(struct dir_struct *dir, const char **pathspec);
-extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
+extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec);
+extern int read_directory(struct dir_struct *, const char *path, int len, const struct pathspec *pathspec);
extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
int *dtype, struct exclude_list *el);
diff --git a/wt-status.c b/wt-status.c
index 13e6aba..2e1a62b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -502,7 +502,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
setup_standard_excludes(&dir);
- fill_directory(&dir, s->pathspec.raw);
+ fill_directory(&dir, &s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
if (cache_name_is_other(ent->name, ent->len) &&
@@ -514,7 +514,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
if (s->show_ignored_files) {
dir.nr = 0;
dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
- fill_directory(&dir, s->pathspec.raw);
+ fill_directory(&dir, &s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
if (cache_name_is_other(ent->name, ent->len) &&
--
1.8.0.rc2.23.g1fb49df
next prev parent reply other threads:[~2013-01-11 11:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 11:20 [PATCH v2 00/21] nd/parse-pathspec reroll Nguyễn Thái Ngọc Duy
2013-01-11 11:20 ` [PATCH v2 01/21] pathspec: save the non-wildcard length part Nguyễn Thái Ngọc Duy
2013-01-11 11:20 ` [PATCH v2 02/21] Add parse_pathspec() that converts cmdline args to struct pathspec Nguyễn Thái Ngọc Duy
2013-01-11 11:20 ` [PATCH v2 03/21] Export parse_pathspec() and convert some get_pathspec() calls Nguyễn Thái Ngọc Duy
2013-01-11 17:56 ` Matt Kraai
2013-01-12 6:00 ` Duy Nguyen
2013-01-11 11:20 ` [PATCH v2 04/21] clean: convert to use parse_pathspec Nguyễn Thái Ngọc Duy
2013-01-11 11:20 ` [PATCH v2 05/21] commit: " Nguyễn Thái Ngọc Duy
2013-01-12 22:54 ` Martin von Zweigbergk
2013-01-11 11:21 ` [PATCH v2 06/21] status: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 07/21] rerere: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 08/21] checkout: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 09/21] rm: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 10/21] ls-files: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 11/21] archive: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 12/21] add: " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 13/21] Convert read_cache_preload() to take struct pathspec Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 14/21] Convert unmerge_cache " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 15/21] checkout: convert read_tree_some " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 16/21] Convert report_path_error " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 17/21] Convert refresh_index " Nguyễn Thái Ngọc Duy
2013-01-11 14:19 ` Nguyen Thai Ngoc Duy
2013-01-11 11:21 ` Nguyễn Thái Ngọc Duy [this message]
2013-01-11 11:21 ` [PATCH v2 19/21] Convert add_files_to_cache " Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 20/21] Convert more init_pathspec() to parse_pathspec() Nguyễn Thái Ngọc Duy
2013-01-11 11:21 ` [PATCH v2 21/21] Rename field "raw" to "_raw" in struct pathspec Nguyễn Thái Ngọc Duy
2013-01-11 14:26 ` [PATCH v2 22/21] Convert the last use of match_pathspec() and remove it Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357903275-16804-19-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).