]>
Commit | Line | Data |
---|---|---|
d052cc03 MT |
1 | #ifndef ENTRY_H |
2 | #define ENTRY_H | |
3 | ||
d052cc03 MT |
4 | #include "convert.h" |
5 | ||
ba3d1c73 EN |
6 | struct cache_entry; |
7 | struct index_state; | |
8 | ||
d052cc03 MT |
9 | struct checkout { |
10 | struct index_state *istate; | |
11 | const char *base_dir; | |
12 | int base_dir_len; | |
4002ec3d | 13 | const char *super_prefix; |
d052cc03 MT |
14 | struct delayed_checkout *delayed_checkout; |
15 | struct checkout_metadata meta; | |
16 | unsigned force:1, | |
17 | quiet:1, | |
18 | not_new:1, | |
19 | clone:1, | |
20 | refresh_cache:1; | |
21 | }; | |
f69a6e4f | 22 | #define CHECKOUT_INIT { .base_dir = "" } |
d052cc03 MT |
23 | |
24 | #define TEMPORARY_FILENAME_LENGTH 25 | |
25 | /* | |
26 | * Write the contents from ce out to the working tree. | |
27 | * | |
28 | * When topath[] is not NULL, instead of writing to the working tree | |
29 | * file named by ce, a temporary file is created by this function and | |
30 | * its name is returned in topath[], which must be able to hold at | |
31 | * least TEMPORARY_FILENAME_LENGTH bytes long. | |
ae22751f MT |
32 | * |
33 | * With checkout_entry_ca(), callers can optionally pass a preloaded | |
34 | * conv_attrs struct (to avoid reloading it), when ce refers to a | |
35 | * regular file. If ca is NULL, the attributes will be loaded | |
36 | * internally when (and if) needed. | |
d052cc03 | 37 | */ |
ae22751f MT |
38 | int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca, |
39 | const struct checkout *state, char *topath, | |
40 | int *nr_checkouts); | |
41 | static inline int checkout_entry(struct cache_entry *ce, | |
42 | const struct checkout *state, char *topath, | |
43 | int *nr_checkouts) | |
44 | { | |
45 | return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts); | |
46 | } | |
d052cc03 MT |
47 | |
48 | void enable_delayed_checkout(struct checkout *state); | |
611c7785 | 49 | int finish_delayed_checkout(struct checkout *state, int show_progress); |
d052cc03 MT |
50 | |
51 | /* | |
52 | * Unlink the last component and schedule the leading directories for | |
53 | * removal, such that empty directories get removed. | |
4002ec3d ÆAB |
54 | * |
55 | * The "super_prefix" is either NULL, or the "--super-prefix" passed | |
56 | * down from "read-tree" et al. | |
d052cc03 | 57 | */ |
4002ec3d | 58 | void unlink_entry(const struct cache_entry *ce, const char *super_prefix); |
d052cc03 | 59 | |
e9aa762c | 60 | void *read_blob_entry(const struct cache_entry *ce, size_t *size); |
49cfd903 | 61 | int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st); |
584a0d13 MT |
62 | void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, |
63 | struct stat *st); | |
49cfd903 | 64 | |
afd2a1d5 CW |
65 | /* |
66 | * Calls the correct function out of {unlink,rmdir}_or_warn based on | |
67 | * the supplied file mode. | |
68 | */ | |
69 | int remove_or_warn(unsigned int mode, const char *path); | |
70 | ||
d052cc03 | 71 | #endif /* ENTRY_H */ |