Imported Upstream version 2.29.0
[platform/upstream/git.git] / archive.h
1 #ifndef ARCHIVE_H
2 #define ARCHIVE_H
3
4 #include "cache.h"
5 #include "pathspec.h"
6
7 struct repository;
8
9 struct archiver_args {
10         struct repository *repo;
11         const char *refname;
12         const char *prefix;
13         const char *base;
14         size_t baselen;
15         struct tree *tree;
16         const struct object_id *commit_oid;
17         const struct commit *commit;
18         timestamp_t time;
19         struct pathspec pathspec;
20         unsigned int verbose : 1;
21         unsigned int worktree_attributes : 1;
22         unsigned int convert : 1;
23         int compression_level;
24         struct string_list extra_files;
25 };
26
27 /* main api */
28
29 int write_archive(int argc, const char **argv, const char *prefix,
30                   struct repository *repo,
31                   const char *name_hint, int remote);
32
33 const char *archive_format_from_filename(const char *filename);
34
35 /* archive backend stuff */
36
37 #define ARCHIVER_WANT_COMPRESSION_LEVELS 1
38 #define ARCHIVER_REMOTE 2
39 struct archiver {
40         const char *name;
41         int (*write_archive)(const struct archiver *, struct archiver_args *);
42         unsigned flags;
43         void *data;
44 };
45 void register_archiver(struct archiver *);
46
47 void init_tar_archiver(void);
48 void init_zip_archiver(void);
49 void init_archivers(void);
50
51 typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,
52                                         const struct object_id *oid,
53                                         const char *path, size_t pathlen,
54                                         unsigned int mode,
55                                         void *buffer, unsigned long size);
56
57 int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
58
59 #endif  /* ARCHIVE_H */