]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pathspec doc: parse_pathspec does not maintain references to args
authorJonathan Nieder <jrnieder@gmail.com>
Thu, 21 Sep 2017 04:41:12 +0000 (21:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Sep 2017 05:05:00 +0000 (14:05 +0900)
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>
pathspec.c
pathspec.h

index e2a23ebc9668b066d337391e96139af49907edfa..cdefdc7cc0e0be248297d1191eefe72418923f7a 100644 (file)
@@ -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)
index 60e6500401e687bc0d764c38c5d8b4928b7bfde8..6420d1080ae4165ad81b60376c714bd178463b6a 100644 (file)
@@ -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,