Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 1 | #ifndef ARCHIVE_H |
| 2 | #define ARCHIVE_H |
| 3 | |
Nguyễn Thái Ngọc Duy | f3e743a | 2013-07-14 15:35:44 +0700 | [diff] [blame] | 4 | #include "pathspec.h" |
Elijah Newren | b7b189c | 2023-04-11 00:42:03 -0700 | [diff] [blame] | 5 | #include "string-list.h" |
Nguyễn Thái Ngọc Duy | f3e743a | 2013-07-14 15:35:44 +0700 | [diff] [blame] | 6 | |
Nguyễn Thái Ngọc Duy | b612ee2 | 2018-08-13 18:14:35 +0200 | [diff] [blame] | 7 | struct repository; |
René Scharfe | 9609972 | 2021-02-28 12:22:47 +0100 | [diff] [blame] | 8 | struct pretty_print_context; |
Nguyễn Thái Ngọc Duy | b612ee2 | 2018-08-13 18:14:35 +0200 | [diff] [blame] | 9 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 10 | struct archiver_args { |
Nguyễn Thái Ngọc Duy | b612ee2 | 2018-08-13 18:14:35 +0200 | [diff] [blame] | 11 | struct repository *repo; |
René Scharfe | 1c3e412 | 2020-11-14 23:01:04 +0100 | [diff] [blame] | 12 | char *refname; |
René Scharfe | 2947a79 | 2020-09-19 23:23:42 +0200 | [diff] [blame] | 13 | const char *prefix; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 14 | const char *base; |
René Scharfe | d53fe81 | 2008-07-15 09:49:38 +0200 | [diff] [blame] | 15 | size_t baselen; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 16 | struct tree *tree; |
brian m. carlson | bbf05cf | 2019-02-19 00:05:20 +0000 | [diff] [blame] | 17 | const struct object_id *commit_oid; |
René Scharfe | 8460b2f | 2007-09-03 20:07:01 +0200 | [diff] [blame] | 18 | const struct commit *commit; |
René Scharfe | fd2da4b | 2023-02-18 09:36:23 +0100 | [diff] [blame] | 19 | const char *mtime_option; |
Johannes Schindelin | dddbad7 | 2017-04-26 21:29:31 +0200 | [diff] [blame] | 20 | timestamp_t time; |
Nguyễn Thái Ngọc Duy | f3e743a | 2013-07-14 15:35:44 +0700 | [diff] [blame] | 21 | struct pathspec pathspec; |
Junio C Hamano | e0ffb24 | 2006-09-09 22:42:02 -0700 | [diff] [blame] | 22 | unsigned int verbose : 1; |
Nguyễn Thái Ngọc Duy | ba053ea | 2009-04-18 00:18:05 +0200 | [diff] [blame] | 23 | unsigned int worktree_attributes : 1; |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 24 | unsigned int convert : 1; |
René Scharfe | 3a176c6 | 2008-07-18 16:30:32 +0200 | [diff] [blame] | 25 | int compression_level; |
René Scharfe | 2947a79 | 2020-09-19 23:23:42 +0200 | [diff] [blame] | 26 | struct string_list extra_files; |
René Scharfe | 9609972 | 2021-02-28 12:22:47 +0100 | [diff] [blame] | 27 | struct pretty_print_context *pretty_ctx; |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
Nguyễn Thái Ngọc Duy | b612ee2 | 2018-08-13 18:14:35 +0200 | [diff] [blame] | 30 | /* main api */ |
| 31 | |
Denton Liu | 5545442 | 2019-04-29 04:28:14 -0400 | [diff] [blame] | 32 | int write_archive(int argc, const char **argv, const char *prefix, |
Denton Liu | ad6dad0 | 2019-04-29 04:28:23 -0400 | [diff] [blame] | 33 | struct repository *repo, |
| 34 | const char *name_hint, int remote); |
Nguyễn Thái Ngọc Duy | b612ee2 | 2018-08-13 18:14:35 +0200 | [diff] [blame] | 35 | |
| 36 | const char *archive_format_from_filename(const char *filename); |
| 37 | |
| 38 | /* archive backend stuff */ |
| 39 | |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 40 | #define ARCHIVER_WANT_COMPRESSION_LEVELS 1 |
Jeff King | 7b97730 | 2011-06-21 23:17:35 -0400 | [diff] [blame] | 41 | #define ARCHIVER_REMOTE 2 |
René Scharfe | cde8ea9 | 2020-11-09 17:05:31 +0100 | [diff] [blame] | 42 | #define ARCHIVER_HIGH_COMPRESSION_LEVELS 4 |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 43 | struct archiver { |
| 44 | const char *name; |
Jeff King | 4d7c989 | 2011-06-21 21:24:07 -0400 | [diff] [blame] | 45 | int (*write_archive)(const struct archiver *, struct archiver_args *); |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 46 | unsigned flags; |
René Scharfe | 96b9e51 | 2022-06-15 18:59:57 +0200 | [diff] [blame] | 47 | char *filter_command; |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 48 | }; |
Denton Liu | 5545442 | 2019-04-29 04:28:14 -0400 | [diff] [blame] | 49 | void register_archiver(struct archiver *); |
Jeff King | 13e0f88 | 2011-06-21 21:23:33 -0400 | [diff] [blame] | 50 | |
Denton Liu | 5545442 | 2019-04-29 04:28:14 -0400 | [diff] [blame] | 51 | void init_tar_archiver(void); |
| 52 | void init_zip_archiver(void); |
| 53 | void init_archivers(void); |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 54 | |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 55 | typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, |
brian m. carlson | 015ff4f | 2018-03-12 02:27:35 +0000 | [diff] [blame] | 56 | const struct object_id *oid, |
Nguyễn Thái Ngọc Duy | 9cb513b | 2012-05-03 08:51:03 +0700 | [diff] [blame] | 57 | const char *path, size_t pathlen, |
René Scharfe | 200589a | 2020-09-19 23:23:32 +0200 | [diff] [blame] | 58 | unsigned int mode, |
| 59 | void *buffer, unsigned long size); |
René Scharfe | 562e25a | 2008-07-14 21:22:24 +0200 | [diff] [blame] | 60 | |
Denton Liu | 5545442 | 2019-04-29 04:28:14 -0400 | [diff] [blame] | 61 | int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry); |
René Scharfe | 562e25a | 2008-07-14 21:22:24 +0200 | [diff] [blame] | 62 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 63 | #endif /* ARCHIVE_H */ |