Skip to content

Commit 29c0e90

Browse files
jrngitster
authored andcommitted
pathspec doc: parse_pathspec does not maintain references to args
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7fa3c2a commit 29c0e90

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pathspec.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ static void NORETURN unsupported_magic(const char *pattern,
526526
pattern, sb.buf);
527527
}
528528

529-
/*
530-
* Given command line arguments and a prefix, convert the input to
531-
* pathspec. die() if any magic in magic_mask is used.
532-
*/
533529
void parse_pathspec(struct pathspec *pathspec,
534530
unsigned magic_mask, unsigned flags,
535531
const char *prefix, const char **argv)

pathspec.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ struct pathspec {
7070
*/
7171
#define PATHSPEC_LITERAL_PATH (1<<6)
7272

73+
/*
74+
* Given command line arguments and a prefix, convert the input to
75+
* pathspec. die() if any magic in magic_mask is used.
76+
*
77+
* Any arguments used are copied. It is safe for the caller to modify
78+
* or free 'prefix' and 'args' after calling this function.
79+
*/
7380
extern void parse_pathspec(struct pathspec *pathspec,
7481
unsigned magic_mask,
7582
unsigned flags,

0 commit comments

Comments
 (0)