| 685 | } |
| 686 | |
| 687 | void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask, |
| 688 | unsigned flags, const char *prefix, |
| 689 | const char *file, int nul_term_line) |
| 690 | { |
| 691 | struct strvec parsed_file = STRVEC_INIT; |
| 692 | strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul : |
| 693 | strbuf_getline; |
| 694 | struct strbuf buf = STRBUF_INIT; |
| 695 | struct strbuf unquoted = STRBUF_INIT; |
| 696 | FILE *in; |
| 697 | |
| 698 | if (!strcmp(file, "-")) |
| 699 | in = stdin; |
| 700 | else |
| 701 | in = xfopen(file, "r"); |
| 702 | |
| 703 | while (getline_fn(&buf, in) != EOF) { |
| 704 | if (!nul_term_line && buf.buf[0] == '"') { |
| 705 | strbuf_reset(&unquoted); |
| 706 | if (unquote_c_style(&unquoted, buf.buf, NULL)) |
| 707 | die(_("line is badly quoted: %s"), buf.buf); |
| 708 | strbuf_swap(&buf, &unquoted); |
| 709 | } |
| 710 | strvec_push(&parsed_file, buf.buf); |
| 711 | strbuf_reset(&buf); |
| 712 | } |
| 713 | |
| 714 | strbuf_release(&unquoted); |
| 715 | strbuf_release(&buf); |
| 716 | if (in != stdin) |
| 717 | fclose(in); |
| 718 | |
| 719 | parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.v); |
| 720 | strvec_clear(&parsed_file); |
| 721 | } |
| 722 | |
| 723 | void copy_pathspec(struct pathspec *dst, const struct pathspec *src) |
| 724 | { |
no test coverage detected