summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fdee7d0)
raw | patch | inline | side by side (parent: fdee7d0)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 23:55:06 +0000 (16:55 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 23:55:06 +0000 (16:55 -0700) |
... and make git-diff-files use it too. This all _should_ make the
diffcore-pathspec.c phase unnecessary, since the diff'ers now all do the
path matching early interally.
diffcore-pathspec.c phase unnecessary, since the diff'ers now all do the
path matching early interally.
cache.h | patch | blob | history | |
diff-cache.c | patch | blob | history | |
diff-files.c | patch | blob | history | |
read-cache.c | patch | blob | history |
index 36cb4ae1f51678b088b7340aa470e029d5a47afe..35e0ad7e0e0d6b58e0316ae52214509c99fdc89a 100644 (file)
--- a/cache.h
+++ b/cache.h
extern int remove_file_from_cache(char *path);
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
extern int ce_match_stat(struct cache_entry *ce, struct stat *st);
+extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type);
extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
diff --git a/diff-cache.c b/diff-cache.c
index 37c6eb5804ec7a454b0df83809e0208bcbd1b766..e6373b3484d1102274f85a8711a69b3af0d3f426 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
return 0;
}
-static int ce_path_match(const struct cache_entry *ce, const char **pathspec)
-{
- const char *match, *name;
- int len;
-
- if (!pathspec)
- return 1;
-
- len = ce_namelen(ce);
- name = ce->name;
- while ((match = *pathspec++) != NULL) {
- int matchlen = strlen(match);
- if (matchlen > len)
- continue;
- if (memcmp(name, match, matchlen))
- continue;
- if (name[matchlen] == '/' || !name[matchlen])
- return 1;
- }
- return 0;
-}
-
static int diff_cache(struct cache_entry **ac, int entries, const char **pathspec)
{
while (entries) {
diff --git a/diff-files.c b/diff-files.c
index ebaf235c52f570c3bbe90bbfd4ad7d9e805f476f..4e7d9673ce95cb0de71bdca1d73ec017781039ec 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
int main(int argc, const char **argv)
{
static const unsigned char null_sha1[20] = { 0, };
+ const char **pathspec;
int entries = read_cache();
int i;
argv++; argc--;
}
+ /* Do we have a pathspec? */
+ pathspec = (argc > 1) ? argv + 1 : NULL;
+
if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
usage(diff_files_usage);
struct cache_entry *ce = active_cache[i];
int changed;
+ if (!ce_path_match(ce, pathspec))
+ continue;
+
if (ce_stage(ce)) {
show_unmerge(ce->name);
while (i < entries &&
ce->sha1, (changed ? null_sha1 : ce->sha1),
ce->name);
}
- diffcore_std((1 < argc) ? argv + 1 : NULL,
+ diffcore_std(pathspec,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
diff --git a/read-cache.c b/read-cache.c
index 5a61bf752bdc15f311215f91ea923f5422e8ad5c..f448ab17e279d2fb4e2cfa91cfc61be6f91128db 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)
+{
+ const char *match, *name;
+ int len;
+
+ if (!pathspec)
+ return 1;
+
+ len = ce_namelen(ce);
+ name = ce->name;
+ while ((match = *pathspec++) != NULL) {
+ int matchlen = strlen(match);
+ if (matchlen > len)
+ continue;
+ if (memcmp(name, match, matchlen))
+ continue;
+ if (matchlen && name[matchlen-1] == '/')
+ return 1;
+ if (name[matchlen] == '/' || !name[matchlen])
+ return 1;
+ }
+ return 0;
+}
+
/*
* Do we have another file that has the beginning components being a
* proper superset of the name we're trying to add?