summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ec56c4d)
raw | patch | inline | side by side (parent: ec56c4d)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Fri, 17 Dec 2010 12:43:07 +0000 (19:43 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 17 Dec 2010 22:40:59 +0000 (14:40 -0800) |
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-index.c | patch | blob | history | |
cache.h | patch | blob | history | |
diff-lib.c | patch | blob | history | |
preload-index.c | patch | blob | history | |
read-cache.c | patch | blob | history | |
revision.c | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 3ab214d24e537865875d6d1e3acd8cf6b019ff22..9d1f67e64cb1cf32da1121f8d8bb37a72404c69c 100644 (file)
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
*/
int pos;
int has_head = 1;
- const char **pathspec = get_pathspec(prefix, av + 1);
+ const char **paths = get_pathspec(prefix, av + 1);
+ struct pathspec pathspec;
+
+ init_pathspec(&pathspec, paths);
if (read_ref("HEAD", head_sha1))
/* If there is no HEAD, that means it is an initial
struct cache_entry *old = NULL;
int save_nr;
- if (ce_stage(ce) || !ce_path_match(ce, pathspec))
+ if (ce_stage(ce) || !ce_path_match(ce, &pathspec))
continue;
if (has_head)
old = read_one_ent(NULL, head_sha1,
if (save_nr != active_nr)
goto redo;
}
+ free_pathspec(&pathspec);
return 0;
}
index dc0bfb4d78dbb28572f4948725474e4ccc62b8ad..b5cd61c083ef5f262b2e98f97895f034d111ec4a 100644 (file)
--- a/cache.h
+++ b/cache.h
extern int init_pathspec(struct pathspec *, const char **);
extern void free_pathspec(struct pathspec *);
-extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
+extern int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec);
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
diff --git a/diff-lib.c b/diff-lib.c
index 2251f3df687514acb91a9b4382eb0aac88a7897b..1e22992cb10420b9dd6def16f80efc5f196ffbbb 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
break;
- if (!ce_path_match(ce, revs->prune_data.raw))
+ if (!ce_path_match(ce, &revs->prune_data))
continue;
if (ce_stage(ce)) {
@@ -427,7 +427,7 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
if (tree == o->df_conflict_entry)
tree = NULL;
- if (ce_path_match(idx ? idx : tree, revs->prune_data.raw))
+ if (ce_path_match(idx ? idx : tree, &revs->prune_data))
do_oneway_diff(o, idx, tree);
return 0;
diff --git a/preload-index.c b/preload-index.c
index e3d0bda31a98372eb9b6a8c2cd0fd65917a9dbde..49cb08df96faa90101bb25d8f96acaffc066f19b 100644 (file)
--- a/preload-index.c
+++ b/preload-index.c
struct index_state *index = p->index;
struct cache_entry **cep = index->cache + p->offset;
struct cache_def cache;
+ struct pathspec pathspec;
+ init_pathspec(&pathspec, p->pathspec);
memset(&cache, 0, sizeof(cache));
nr = p->nr;
if (nr + p->offset > index->cache_nr)
continue;
if (ce_uptodate(ce))
continue;
- if (!ce_path_match(ce, p->pathspec))
+ if (!ce_path_match(ce, &pathspec))
continue;
if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
continue;
continue;
ce_mark_uptodate(ce);
} while (--nr > 0);
+ free_pathspec(&pathspec);
return NULL;
}
diff --git a/read-cache.c b/read-cache.c
index 1f42473e8070a05ada8c56b0d60537227a5223ec..f1141a36d8903ed3c14488920cca544622203b09 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
return ce_namelen(b) == len && !memcmp(a->name, b->name, len);
}
-int ce_path_match(const struct cache_entry *ce, const char **pathspec)
+int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec)
{
const char *match, *name;
+ const char **ps = pathspec->raw;
int len;
- if (!pathspec)
+ if (!pathspec->nr)
return 1;
len = ce_namelen(ce);
name = ce->name;
- while ((match = *pathspec++) != NULL) {
+ while ((match = *ps++) != NULL) {
int matchlen = strlen(match);
if (matchlen > len)
continue;
diff --git a/revision.c b/revision.c
index 515e2dd23b5512888c413ae68de435fa40ccfd0e..a0d3816239967a6d65d5b500e853279c7183726c 100644 (file)
--- a/revision.c
+++ b/revision.c
struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce))
continue;
- if (ce_path_match(ce, revs->prune_data.raw)) {
+ if (ce_path_match(ce, &revs->prune_data)) {
prune_num++;
prune = xrealloc(prune, sizeof(*prune) * prune_num);
prune[prune_num-2] = ce->name;
diff --git a/wt-status.c b/wt-status.c
index 5c6b11849b16e9dfe21d6cb99e411a08ba275c3e..457d265f86d7043b7d58ed1135b8a9b503dfb3cd 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
static void wt_status_collect_changes_initial(struct wt_status *s)
{
+ struct pathspec pathspec;
int i;
+ init_pathspec(&pathspec, s->pathspec);
for (i = 0; i < active_nr; i++) {
struct string_list_item *it;
struct wt_status_change_data *d;
struct cache_entry *ce = active_cache[i];
- if (!ce_path_match(ce, s->pathspec))
+ if (!ce_path_match(ce, &pathspec))
continue;
it = string_list_insert(&s->change, ce->name);
d = it->util;
else
d->index_status = DIFF_STATUS_ADDED;
}
+ free_pathspec(&pathspec);
}
static void wt_status_collect_untracked(struct wt_status *s)