blob: bbe65ba0f900df1367d1d7607300d732a86c5c0c [file] [log] [blame]
Franck Bui-Huu4df096a2006-09-07 15:12:02 +02001#ifndef ARCHIVE_H
2#define ARCHIVE_H
3
Nguyễn Thái Ngọc Duyf3e743a2013-07-14 15:35:44 +07004#include "pathspec.h"
Elijah Newrenb7b189c2023-04-11 00:42:03 -07005#include "string-list.h"
Nguyễn Thái Ngọc Duyf3e743a2013-07-14 15:35:44 +07006
Nguyễn Thái Ngọc Duyb612ee22018-08-13 18:14:35 +02007struct repository;
René Scharfe96099722021-02-28 12:22:47 +01008struct pretty_print_context;
Nguyễn Thái Ngọc Duyb612ee22018-08-13 18:14:35 +02009
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020010struct archiver_args {
Nguyễn Thái Ngọc Duyb612ee22018-08-13 18:14:35 +020011 struct repository *repo;
René Scharfe1c3e4122020-11-14 23:01:04 +010012 char *refname;
René Scharfe2947a792020-09-19 23:23:42 +020013 const char *prefix;
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020014 const char *base;
René Scharfed53fe812008-07-15 09:49:38 +020015 size_t baselen;
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020016 struct tree *tree;
brian m. carlsonbbf05cf2019-02-19 00:05:20 +000017 const struct object_id *commit_oid;
René Scharfe8460b2f2007-09-03 20:07:01 +020018 const struct commit *commit;
René Scharfefd2da4b2023-02-18 09:36:23 +010019 const char *mtime_option;
Johannes Schindelindddbad72017-04-26 21:29:31 +020020 timestamp_t time;
Nguyễn Thái Ngọc Duyf3e743a2013-07-14 15:35:44 +070021 struct pathspec pathspec;
Junio C Hamanoe0ffb242006-09-09 22:42:02 -070022 unsigned int verbose : 1;
Nguyễn Thái Ngọc Duyba053ea2009-04-18 00:18:05 +020023 unsigned int worktree_attributes : 1;
Nguyễn Thái Ngọc Duy9cb513b2012-05-03 08:51:03 +070024 unsigned int convert : 1;
René Scharfe3a176c62008-07-18 16:30:32 +020025 int compression_level;
René Scharfe2947a792020-09-19 23:23:42 +020026 struct string_list extra_files;
René Scharfe96099722021-02-28 12:22:47 +010027 struct pretty_print_context *pretty_ctx;
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020028};
29
Nguyễn Thái Ngọc Duyb612ee22018-08-13 18:14:35 +020030/* main api */
31
Denton Liu55454422019-04-29 04:28:14 -040032int write_archive(int argc, const char **argv, const char *prefix,
Denton Liuad6dad02019-04-29 04:28:23 -040033 struct repository *repo,
34 const char *name_hint, int remote);
Nguyễn Thái Ngọc Duyb612ee22018-08-13 18:14:35 +020035
36const char *archive_format_from_filename(const char *filename);
37
38/* archive backend stuff */
39
Jeff King13e0f882011-06-21 21:23:33 -040040#define ARCHIVER_WANT_COMPRESSION_LEVELS 1
Jeff King7b977302011-06-21 23:17:35 -040041#define ARCHIVER_REMOTE 2
René Scharfecde8ea92020-11-09 17:05:31 +010042#define ARCHIVER_HIGH_COMPRESSION_LEVELS 4
Jeff King13e0f882011-06-21 21:23:33 -040043struct archiver {
44 const char *name;
Jeff King4d7c9892011-06-21 21:24:07 -040045 int (*write_archive)(const struct archiver *, struct archiver_args *);
Jeff King13e0f882011-06-21 21:23:33 -040046 unsigned flags;
René Scharfe96b9e512022-06-15 18:59:57 +020047 char *filter_command;
Jeff King13e0f882011-06-21 21:23:33 -040048};
Denton Liu55454422019-04-29 04:28:14 -040049void register_archiver(struct archiver *);
Jeff King13e0f882011-06-21 21:23:33 -040050
Denton Liu55454422019-04-29 04:28:14 -040051void init_tar_archiver(void);
52void init_zip_archiver(void);
53void init_archivers(void);
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020054
Nguyễn Thái Ngọc Duy9cb513b2012-05-03 08:51:03 +070055typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,
brian m. carlson015ff4f2018-03-12 02:27:35 +000056 const struct object_id *oid,
Nguyễn Thái Ngọc Duy9cb513b2012-05-03 08:51:03 +070057 const char *path, size_t pathlen,
René Scharfe200589a2020-09-19 23:23:32 +020058 unsigned int mode,
59 void *buffer, unsigned long size);
René Scharfe562e25a2008-07-14 21:22:24 +020060
Denton Liu55454422019-04-29 04:28:14 -040061int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
René Scharfe562e25a2008-07-14 21:22:24 +020062
Franck Bui-Huu4df096a2006-09-07 15:12:02 +020063#endif /* ARCHIVE_H */