From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 5/6] Convert simple init_pathspec() cases to parse_pathspec()
Date: Wed, 12 Oct 2011 09:44:42 +1100 [thread overview]
Message-ID: <1318373083-13840-6-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1318373083-13840-1-git-send-email-pclouds@gmail.com>
These commands can now take advantage of new pathspec magic, if both
tree_entry_interesting() and match_pathspec_depth() support them properly
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/grep.c | 4 +---
builtin/ls-tree.c | 2 +-
builtin/reset.c | 2 +-
revision.c | 9 +++++----
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index a286692..e171a9d 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -759,7 +759,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
const char *show_in_pager = NULL, *default_pager = "dummy";
struct grep_opt opt;
struct object_array list = OBJECT_ARRAY_INIT;
- const char **paths = NULL;
struct pathspec pathspec;
struct string_list path_list = STRING_LIST_INIT_NODUP;
int i;
@@ -1020,8 +1019,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
verify_filename(prefix, argv[j]);
}
- paths = get_pathspec(prefix, argv + i);
- init_pathspec(&pathspec, paths);
+ parse_pathspec(&pathspec, prefix, -1, argv + i);
pathspec.max_depth = opt.max_depth;
pathspec.recursive = 1;
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index f0fa7dd..b717bb2 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -166,7 +166,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
if (get_sha1(argv[0], sha1))
die("Not a valid object name %s", argv[0]);
- init_pathspec(&pathspec, get_pathspec(prefix, argv + 1));
+ parse_pathspec(&pathspec, prefix, -1, argv + 1);
for (i = 0; i < pathspec.nr; i++)
pathspec.items[i].magic = PATHSPEC_NOGLOB;
pathspec.magic |= PATHSPEC_NOGLOB;
diff --git a/builtin/reset.c b/builtin/reset.c
index 811e8e2..8126e69 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -176,7 +176,7 @@ static int read_from_tree(const char *prefix, const char **argv,
struct diff_options opt;
memset(&opt, 0, sizeof(opt));
- diff_tree_setup_paths(get_pathspec(prefix, (const char **)argv), &opt);
+ parse_pathspec(&opt.pathspec, prefix, -1, argv);
opt.output_format = DIFF_FORMAT_CALLBACK;
opt.format_callback = update_index_from_diff;
opt.format_callback_data = &index_was_discarded;
diff --git a/revision.c b/revision.c
index 9bae329..cba32e8 100644
--- a/revision.c
+++ b/revision.c
@@ -1770,8 +1770,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
*/
ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc);
prune_data.path[prune_data.nr++] = NULL;
- init_pathspec(&revs->prune_data,
- get_pathspec(revs->prefix, prune_data.path));
+ parse_pathspec(&revs->prune_data, revs->prefix, -1, prune_data.path);
}
if (revs->def == NULL)
@@ -1804,12 +1803,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
revs->limited = 1;
if (revs->prune_data.nr) {
- diff_tree_setup_paths(revs->prune_data.raw, &revs->pruning);
+ /* Careful, we share a lot of pointers here, do not free 1st arg */
+ memcpy(&revs->pruning.pathspec, &revs->prune_data, sizeof(struct pathspec));
/* Can't prune commits with rename following: the paths change.. */
if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
revs->prune = 1;
if (!revs->full_diff)
- diff_tree_setup_paths(revs->prune_data.raw, &revs->diffopt);
+ /* Careful, we share a lot of pointers here, do not free 1st arg */
+ memcpy(&revs->diffopt.pathspec, &revs->prune_data, sizeof(struct pathspec));
}
if (revs->combine_merges)
revs->ignore_merges = 0;
--
1.7.3.1.256.g2539c.dirty
next prev parent reply other threads:[~2011-10-11 22:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-11 22:44 [PATCH 0/6] Negation magic pathspec Nguyễn Thái Ngọc Duy
2011-10-11 22:44 ` [PATCH 1/6] Recognize magic pathspec as filenames Nguyễn Thái Ngọc Duy
2011-10-12 20:49 ` Junio C Hamano
2011-10-13 4:23 ` Nguyen Thai Ngoc Duy
2011-10-13 6:06 ` Junio C Hamano
2011-10-11 22:44 ` [PATCH 2/6] Replace has_wildcard with PATHSPEC_NOGLOB Nguyễn Thái Ngọc Duy
2011-10-11 22:44 ` [PATCH 3/6] Convert prefix_pathspec() to produce struct pathspec_item Nguyễn Thái Ngọc Duy
2011-10-11 22:44 ` [PATCH 4/6] Implement parse_pathspec() Nguyễn Thái Ngọc Duy
2011-10-11 22:44 ` Nguyễn Thái Ngọc Duy [this message]
2011-10-13 0:29 ` [PATCH 5/6] Convert simple init_pathspec() cases to parse_pathspec() Junio C Hamano
2011-10-11 22:44 ` [PATCH 6/6] Implement negative pathspec Nguyễn Thái Ngọc Duy
2011-10-11 23:17 ` [PATCH 0/6] Negation magic pathspec Junio C Hamano
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=1318373083-13840-6-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/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).