pathspec: remove the deprecated get_pathspec function

Now that all callers of the old 'get_pathspec' interface have been migrated to use the new pathspec struct interface it can be removed from the codebase. Since there are no more users of the '_raw' field in the pathspec struct it can also be removed. This patch also removes the old functionality of modifying the const char **argv array that was passed into parse_pathspec. Instead the constructed 'match' string (which is a pathspec element with the prefix prepended) is only stored in its corresponding pathspec_item entry. Signed-off-by: Brandon Williams <bmwill@google.com> Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Jan 4, 2017 at 10:04 UTC 34305f7753f9f044cb280e6d58658cb31b140693
4 files changed +3 -43
Documentation/technical/api-setup.txt
-2
@@ -27,8 +27,6 @@ parse_pathspec(). This function takes several arguments:
27
28 - prefix and args come from cmd_* functions
29
30 -get_pathspec() is obsolete and should never be used in new code.
31 -
30 parse_pathspec() helps catch unsupported features and reject them
31 politely. At a lower level, different pathspec-related functions may
32 not support the same set of features. Such pathspec-sensitive
cache.h
-1
@@ -514,7 +514,6 @@ extern void set_git_work_tree(const char *tree);
514
515 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
516
517 -extern const char **get_pathspec(const char *prefix, const char **pathspec);
517 extern void setup_work_tree(void);
518 extern const char *setup_git_directory_gently(int *);
519 extern const char *setup_git_directory(void);
pathspec.c
+3 -39
@@ -103,7 +103,7 @@ static void prefix_short_magic(struct strbuf *sb, int prefixlen,
103 */
104 static unsigned prefix_pathspec(struct pathspec_item *item,
105 unsigned *p_short_magic,
106 - const char **raw, unsigned flags,
106 + unsigned flags,
107 const char *prefix, int prefixlen,
108 const char *elt)
109 {
@@ -240,7 +240,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
240 if (!match)
241 die(_("%s: '%s' is outside repository"), elt, copyfrom);
242 }
243 - *raw = item->match = match;
243 + item->match = match;
244 /*
245 * Prefix the pathspec (keep all magic) and assign to
246 * original. Useful for passing to another command.
@@ -381,8 +381,6 @@ void parse_pathspec(struct pathspec *pathspec,
381
382 /* No arguments with prefix -> prefix pathspec */
383 if (!entry) {
384 - static const char *raw[2];
385 -
384 if (flags & PATHSPEC_PREFER_FULL)
385 return;
386
@@ -394,10 +392,7 @@ void parse_pathspec(struct pathspec *pathspec,
392 item->original = prefix;
393 item->nowildcard_len = item->len = strlen(prefix);
394 item->prefix = item->len;
397 - raw[0] = prefix;
398 - raw[1] = NULL;
395 pathspec->nr = 1;
400 - pathspec->_raw = raw;
396 return;
397 }
398
@@ -415,7 +410,6 @@ void parse_pathspec(struct pathspec *pathspec,
410 pathspec->nr = n;
411 ALLOC_ARRAY(pathspec->items, n);
412 item = pathspec->items;
418 - pathspec->_raw = argv;
413 prefixlen = prefix ? strlen(prefix) : 0;
414
415 for (i = 0; i < n; i++) {
@@ -423,7 +417,7 @@ void parse_pathspec(struct pathspec *pathspec,
417 entry = argv[i];
418
419 item[i].magic = prefix_pathspec(item + i, &short_magic,
426 - argv + i, flags,
420 + flags,
421 prefix, prefixlen, entry);
422 if ((flags & PATHSPEC_LITERAL_PATH) &&
423 !(magic_mask & PATHSPEC_LITERAL))
@@ -457,36 +451,6 @@ void parse_pathspec(struct pathspec *pathspec,
451 }
452 }
453
460 -/*
461 - * N.B. get_pathspec() is deprecated in favor of the "struct pathspec"
462 - * based interface - see pathspec.c:parse_pathspec().
463 - *
464 - * Arguments:
465 - * - prefix - a path relative to the root of the working tree
466 - * - pathspec - a list of paths underneath the prefix path
467 - *
468 - * Iterates over pathspec, prepending each path with prefix,
469 - * and return the resulting list.
470 - *
471 - * If pathspec is empty, return a singleton list containing prefix.
472 - *
473 - * If pathspec and prefix are both empty, return an empty list.
474 - *
475 - * This is typically used by built-in commands such as add.c, in order
476 - * to normalize argv arguments provided to the built-in into a list of
477 - * paths to process, all relative to the root of the working tree.
478 - */
479 -const char **get_pathspec(const char *prefix, const char **pathspec)
480 -{
481 - struct pathspec ps;
482 - parse_pathspec(&ps,
483 - PATHSPEC_ALL_MAGIC &
484 - ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
485 - PATHSPEC_PREFER_CWD,
486 - prefix, pathspec);
487 - return ps._raw;
488 -}
489 -
454 void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
455 {
456 *dst = *src;
pathspec.h
-1
@@ -19,7 +19,6 @@
19 #define PATHSPEC_ONESTAR 1 /* the pathspec pattern satisfies GFNM_ONESTAR */
20
21 struct pathspec {
22 - const char **_raw; /* get_pathspec() result, not freed by clear_pathspec() */
22 int nr;
23 unsigned int has_wildcard:1;
24 unsigned int recursive:1;