| 750 | } |
| 751 | |
| 752 | int write_archive(int argc, const char **argv, const char *prefix, |
| 753 | struct repository *repo, |
| 754 | const char *name_hint, int remote) |
| 755 | { |
| 756 | const struct archiver *ar = NULL; |
| 757 | struct pretty_print_describe_status describe_status = {0}; |
| 758 | struct pretty_print_context ctx = {0}; |
| 759 | struct archiver_args args; |
| 760 | const char **argv_copy; |
| 761 | int rc; |
| 762 | |
| 763 | repo_config_get_bool(the_repository, "uploadarchive.allowunreachable", &remote_allow_unreachable); |
| 764 | repo_config(the_repository, git_default_config, NULL); |
| 765 | |
| 766 | describe_status.max_invocations = 1; |
| 767 | ctx.date_mode.type = DATE_NORMAL; |
| 768 | ctx.abbrev = DEFAULT_ABBREV; |
| 769 | ctx.describe_status = &describe_status; |
| 770 | args.pretty_ctx = &ctx; |
| 771 | args.repo = repo; |
| 772 | args.prefix = prefix; |
| 773 | string_list_init_dup(&args.extra_files); |
| 774 | |
| 775 | /* |
| 776 | * `parse_archive_args()` modifies contents of `argv`, which is what we |
| 777 | * want. Our callers may not want it though, so we create a copy here. |
| 778 | */ |
| 779 | DUP_ARRAY(argv_copy, argv, argc); |
| 780 | argv = argv_copy; |
| 781 | |
| 782 | argc = parse_archive_args(argc, argv, &ar, &args, name_hint, remote); |
| 783 | if (!startup_info->have_repository) { |
| 784 | /* |
| 785 | * We know this will die() with an error, so we could just |
| 786 | * die ourselves; but its error message will be more specific |
| 787 | * than what we could write here. |
| 788 | */ |
| 789 | setup_git_directory(the_repository); |
| 790 | } |
| 791 | |
| 792 | parse_treeish_arg(argv, &args, remote); |
| 793 | parse_pathspec_arg(argv + 1, &args); |
| 794 | |
| 795 | rc = ar->write_archive(ar, &args); |
| 796 | |
| 797 | string_list_clear_func(&args.extra_files, extra_file_info_clear); |
| 798 | free(args.refname); |
| 799 | clear_pathspec(&args.pathspec); |
| 800 | free(argv_copy); |
| 801 | |
| 802 | return rc; |
| 803 | } |
| 804 | |
| 805 | static int match_extension(const char *filename, const char *ext) |
| 806 | { |
no test coverage detected