From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: "Stefan Beller" <sbeller@google.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] builtin/mv: Get rid of the last caller of get_pathspec
Date: Mon, 3 Aug 2015 10:53:02 -0700 [thread overview]
Message-ID: <1438624382-31248-1-git-send-email-sbeller@google.com> (raw)
`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@gmx.de>
CC: Junio C Hamano <gitster@pobox.com>
CC: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
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
next reply other threads:[~2015-08-03 17:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 17:53 Stefan Beller [this message]
2015-08-03 22:48 ` [PATCH] builtin/mv: Get rid of the last caller of get_pathspec Eric Sunshine
2015-08-06 18:27 ` [PATCH 0/2] Remove get_pathspec finally Stefan Beller
2015-08-06 18:27 ` [PATCH 1/2] builtin/mv: remove get_pathspec() Stefan Beller
2015-08-06 18:46 ` Eric Sunshine
2015-08-06 18:58 ` Stefan Beller
2015-08-06 20:18 ` Eric Sunshine
2015-08-06 20:59 ` Stefan Beller
2015-08-06 18:27 ` [PATCH 2/2] pathspec: remove deprecated get_pathspec Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438624382-31248-1-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).