path: root/pathspec.h
diff options
authorAlexandr Miloslavskiy <>2019-11-19 16:48:51 (GMT)
committerJunio C Hamano <>2019-11-20 04:01:53 (GMT)
commit24e4750c969b844536af1d286e7d977c74c078a2 (patch)
tree0b5be5c3f0873076b4035fb7d4ec67f37f53f160 /pathspec.h
parentadd97702ed7cc3aa57b15c50b72606eb2f2f8cf5 (diff)
pathspec: add new function to parse file
This will be used to support the new option '--pathspec-from-file' in `git add`, `git-commit`, `git reset` etc. Note also that we specifically handle CR/LF line endings to support Windows better. To simplify code, file is first parsed into `argv_array`. This allows to avoid refactoring `parse_pathspec()`. I considered adding `nul_term_line` to `flags` instead, but decided that it doesn't fit there. The new code is mostly taken from `cmd_update_index()` and `split_mail_conv()`. Co-authored-by: Johannes Schindelin <> Signed-off-by: Alexandr Miloslavskiy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'pathspec.h')
1 files changed, 10 insertions, 0 deletions
diff --git a/pathspec.h b/pathspec.h
index 1c18a2c..a27dc81 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -85,6 +85,16 @@ void parse_pathspec(struct pathspec *pathspec,
unsigned flags,
const char *prefix,
const char **args);
+ * Same as parse_pathspec() but uses file as input.
+ * When 'file' is exactly "-" it uses 'stdin' instead.
+ */
+void parse_pathspec_file(struct pathspec *pathspec,
+ unsigned magic_mask,
+ unsigned flags,
+ const char *prefix,
+ const char *file,
+ int nul_term_line);
void copy_pathspec(struct pathspec *dst, const struct pathspec *src);
void clear_pathspec(struct pathspec *);