`get_pathspec` is deprecated and builtin/mv is its last caller, so getting rid of `get_pathspec` is rather easy. By getting rid of `get_pathspec`, the documentation such as 'technical/api-setup.txt' becomes easier to read as the reader doesn't need to bear with the additional fact that `get_pathspec` is deprecated. The code in 'builtin/mv' still requires some work to make it less ugly. CC: Johannes Schindelin <Johannes.Schindelin@xxxxxx> CC: Junio C Hamano <gitster@xxxxxxxxx> CC: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- Documentation/technical/api-setup.txt | 2 -- builtin/mv.c | 19 ++++++++++++++++--- cache.h | 1 - pathspec.c | 30 ------------------------------ 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/Documentation/technical/api-setup.txt b/Documentation/technical/api-setup.txt index 540e455..eb1fa98 100644 --- a/Documentation/technical/api-setup.txt +++ b/Documentation/technical/api-setup.txt @@ -27,8 +27,6 @@ parse_pathspec(). This function takes several arguments: - prefix and args come from cmd_* functions -get_pathspec() is obsolete and should never be used in new code. - parse_pathspec() helps catch unsupported features and reject them politely. At a lower level, different pathspec-related functions may not support the same set of features. Such pathspec-sensitive diff --git a/builtin/mv.c b/builtin/mv.c index d1d4316..b89d90a 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -10,6 +10,7 @@ #include "string-list.h" #include "parse-options.h" #include "submodule.h" +#include "pathspec.h" static const char * const builtin_mv_usage[] = { N_("git mv [<options>] <source>... <destination>"), @@ -20,13 +21,19 @@ static const char * const builtin_mv_usage[] = { #define KEEP_TRAILING_SLASH 2 static const char **internal_copy_pathspec(const char *prefix, - const char **pathspec, + const char **argv, int count, unsigned flags) { int i; + struct pathspec ps; const char **result = xmalloc((count + 1) * sizeof(const char *)); - memcpy(result, pathspec, count * sizeof(const char *)); + memcpy(result, argv, count * sizeof(const char *)); result[count] = NULL; + + /* + * NEEDSWORK: instead of preprocessing, pass the right flags to + * parse_pathspec below. + */ for (i = 0; i < count; i++) { int length = strlen(result[i]); int to_copy = length; @@ -42,7 +49,13 @@ static const char **internal_copy_pathspec(const char *prefix, result[i] = it; } } - return get_pathspec(prefix, result); + + parse_pathspec(&ps, + PATHSPEC_ALL_MAGIC & + ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL), + PATHSPEC_PREFER_CWD, + prefix, result); + return ps._raw; } static const char *add_slash(const char *path) diff --git a/cache.h b/cache.h index 4f55466..d4e22e2 100644 --- a/cache.h +++ b/cache.h @@ -452,7 +452,6 @@ extern void set_git_work_tree(const char *tree); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" -extern const char **get_pathspec(const char *prefix, const char **pathspec); extern void setup_work_tree(void); extern const char *setup_git_directory_gently(int *); extern const char *setup_git_directory(void); diff --git a/pathspec.c b/pathspec.c index 9304ee3..b0e14e5 100644 --- a/pathspec.c +++ b/pathspec.c @@ -450,36 +450,6 @@ void parse_pathspec(struct pathspec *pathspec, } } -/* - * N.B. get_pathspec() is deprecated in favor of the "struct pathspec" - * based interface - see pathspec.c:parse_pathspec(). - * - * Arguments: - * - prefix - a path relative to the root of the working tree - * - pathspec - a list of paths underneath the prefix path - * - * Iterates over pathspec, prepending each path with prefix, - * and return the resulting list. - * - * If pathspec is empty, return a singleton list containing prefix. - * - * If pathspec and prefix are both empty, return an empty list. - * - * This is typically used by built-in commands such as add.c, in order - * to normalize argv arguments provided to the built-in into a list of - * paths to process, all relative to the root of the working tree. - */ -const char **get_pathspec(const char *prefix, const char **pathspec) -{ - struct pathspec ps; - parse_pathspec(&ps, - PATHSPEC_ALL_MAGIC & - ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL), - PATHSPEC_PREFER_CWD, - prefix, pathspec); - return ps._raw; -} - void copy_pathspec(struct pathspec *dst, const struct pathspec *src) { *dst = *src; -- 2.5.0.2.g6ffee06.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html