diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2017-09-20 21:41:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-21 14:05:00 +0900 |
commit | 29c0e902a803d8865b9421edadf2ca7c565e355c (patch) | |
tree | 6d4948dbea4d83ebe123ee336285d7dfdd620529 | |
parent | 7fa3c2ad6d06428dcbd801ced55dffd22027cc96 (diff) | |
download | git-jk/revision-remove-cmdline-pathspec.tar.gz |
pathspec doc: parse_pathspec does not maintain references to argsjk/revision-remove-cmdline-pathspec
The command line arguments passed to main() are valid for the life of
a program, but the same is not true for all other argv-style arrays
(e.g. when a caller creates an argv_array). Clarify that
parse_pathspec does not rely on the argv passed to it to remain valid.
This makes it easier to tell that callers like "git rev-list --stdin"
are safe and ensures that that is more likely to remain true as the
implementation of parse_pathspec evolves.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | pathspec.c | 4 | ||||
-rw-r--r-- | pathspec.h | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/pathspec.c b/pathspec.c index e2a23ebc96..cdefdc7cc0 100644 --- a/pathspec.c +++ b/pathspec.c @@ -526,10 +526,6 @@ static void NORETURN unsupported_magic(const char *pattern, pattern, sb.buf); } -/* - * Given command line arguments and a prefix, convert the input to - * pathspec. die() if any magic in magic_mask is used. - */ void parse_pathspec(struct pathspec *pathspec, unsigned magic_mask, unsigned flags, const char *prefix, const char **argv) diff --git a/pathspec.h b/pathspec.h index 60e6500401..6420d1080a 100644 --- a/pathspec.h +++ b/pathspec.h @@ -70,6 +70,13 @@ struct pathspec { */ #define PATHSPEC_LITERAL_PATH (1<<6) +/* + * Given command line arguments and a prefix, convert the input to + * pathspec. die() if any magic in magic_mask is used. + * + * Any arguments used are copied. It is safe for the caller to modify + * or free 'prefix' and 'args' after calling this function. + */ extern void parse_pathspec(struct pathspec *pathspec, unsigned magic_mask, unsigned flags, |