v4 addresses a few comments from Duy.
* [2/16] push the guard pathspec macro into simplify_away() and
exclude_matches_pathsepc().
* [6/16] when freeing a pathspec struct, set pathsepc->nr = 0.
* [8/16] tweak the die message when using unsupported magic to be more human
readable.
Brandon Williams (16):
mv: remove use of deprecated 'get_pathspec()'
dir: remove struct path_simplify
dir: convert fill_directory to use the pathspec struct interface
ls-tree: convert show_recursive to use the pathspec struct interface
pathspec: remove the deprecated get_pathspec function
pathspec: copy and free owned memory
pathspec: remove unused variable from unsupported_magic
pathspec: always show mnemonic and name in unsupported_magic
pathspec: simpler logic to prefix original pathspec elements
pathspec: factor global magic into its own function
pathspec: create parse_short_magic function
pathspec: create parse_long_magic function
pathspec: create parse_element_magic helper
pathspec: create strip submodule slash helpers
pathspec: small readability changes
pathspec: rename prefix_pathspec to init_pathspec_item
Documentation/technical/api-setup.txt | 2 -
builtin/ls-tree.c | 16 +-
builtin/mv.c | 50 ++--
cache.h | 1 -
dir.c | 193 ++++++--------
pathspec.c | 480 +++++++++++++++++++---------------
pathspec.h | 5 +-
7 files changed, 390 insertions(+), 357 deletions(-)
--- interdiff between v3 and v4
diff --git a/dir.c b/dir.c
index 15f7c9993..e8ddd7f8a 100644
--- a/dir.c
+++ b/dir.c
@@ -1353,6 +1353,15 @@ static int simplify_away(const char *path, int pathlen,
{
int i;
+ if (pathspec)
+ guard_pathspec(pathspec,
+ pathspec_fromtop |
+ pathspec_maxdepth |
+ pathspec_literal |
+ pathspec_glob |
+ pathspec_icase |
+ pathspec_exclude);
+
if (!pathspec || !pathspec->nr)
return 0;
@@ -1385,6 +1394,15 @@ static int exclude_matches_pathspec(const char *path,
int pathlen,
{
int i;
+ if (pathspec)
+ guard_pathspec(pathspec,
+ pathspec_fromtop |
+ pathspec_maxdepth |
+ pathspec_literal |
+ pathspec_glob |
+ pathspec_icase |
+ pathspec_exclude);
+
if (!pathspec || !pathspec->nr)
return 0;
@@ -1996,15 +2014,6 @@ int read_directory(struct dir_struct *dir, const char
*path,
{
struct untracked_cache_dir *untracked;
- if (pathspec)
- guard_pathspec(pathspec,
- pathspec_fromtop |
- pathspec_maxdepth |
- pathspec_literal |
- pathspec_glob |
- pathspec_icase |
- pathspec_exclude);
-
if (has_symlink_leading_path(path, len))
return dir->nr;
diff --git a/pathspec.c b/pathspec.c
index d4efcf666..bcf3ba039 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -414,10 +414,11 @@ static void NORETURN unsupported_magic(const char
*pattern,
if (!(magic & m->bit))
continue;
if (sb.len)
- strbuf_addch(&sb, ' ');
+ strbuf_addstr(&sb, ", ");
if (m->mnemonic)
- strbuf_addf(&sb, "'(%c)%s'", m->mnemonic, m->name);
+ strbuf_addf(&sb, "'%s' (mnemonic: '%c')",
+ m->name, m->mnemonic);
else
strbuf_addf(&sb, "'%s'", m->name);
}
@@ -544,4 +545,5 @@ void clear_pathspec(struct pathspec *pathspec)
}
free(pathspec->items);
pathspec->items = NULL;
+ pathspec->nr = 0;
}
--
2.11.0.390.gc69c2f50cf-goog