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