pathspec: rename prefix_pathspec to init_pathspec_item

Give a more relevant name to the prefix_pathspec function as it does more than just prefix a pathspec element. 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 27ec42826e9e5ffa9bcdf0208c1399f62b78c7fb
1 file changed +7 -17
pathspec.c
+7 -17
@@ -297,21 +297,11 @@ static void strip_submodule_slash_expensive(struct pathspec_item *item)
297 }
298
299 /*
300 - * Take an element of a pathspec and check for magic signatures.
301 - * Append the result to the prefix. Return the magic bitmap.
302 - *
303 - * For now, we only parse the syntax and throw out anything other than
304 - * "top" magic.
305 - *
306 - * NEEDSWORK: This needs to be rewritten when we start migrating
307 - * get_pathspec() users to use the "struct pathspec" interface. For
308 - * example, a pathspec element may be marked as case-insensitive, but
309 - * the prefix part must always match literally, and a single stupid
310 - * string cannot express such a case.
300 + * Perform the initialization of a pathspec_item based on a pathspec element.
301 */
312 -static unsigned prefix_pathspec(struct pathspec_item *item, unsigned flags,
313 - const char *prefix, int prefixlen,
314 - const char *elt)
302 +static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
303 + const char *prefix, int prefixlen,
304 + const char *elt)
305 {
306 unsigned magic = 0, element_magic = 0;
307 const char *copyfrom = elt;
@@ -329,6 +319,8 @@ static unsigned prefix_pathspec(struct pathspec_item *item, unsigned flags,
319 magic |= get_global_magic(element_magic);
320 }
321
322 + item->magic = magic;
323 +
324 if (pathspec_prefix >= 0 &&
325 (prefixlen || (prefix && *prefix)))
326 die("BUG: 'prefix' magic is supposed to be used at worktree's root");
@@ -401,7 +393,6 @@ static unsigned prefix_pathspec(struct pathspec_item *item, unsigned flags,
393 /* sanity checks, pathspec matchers assume these are sane */
394 assert(item->nowildcard_len <= item->len &&
395 item->prefix <= item->len);
404 - return magic;
396 }
397
398 static int pathspec_item_cmp(const void *a_, const void *b_)
@@ -501,8 +492,7 @@ void parse_pathspec(struct pathspec *pathspec,
492 for (i = 0; i < n; i++) {
493 entry = argv[i];
494
504 - item[i].magic = prefix_pathspec(item + i, flags,
505 - prefix, prefixlen, entry);
495 + init_pathspec_item(item + i, flags, prefix, prefixlen, entry);
496
497 if (item[i].magic & PATHSPEC_EXCLUDE)
498 nr_exclude++;