Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 1 | #ifndef ENTRY_H |
| 2 | #define ENTRY_H |
| 3 | |
| 4 | #include "cache.h" |
| 5 | #include "convert.h" |
| 6 | |
| 7 | struct checkout { |
| 8 | struct index_state *istate; |
| 9 | const char *base_dir; |
| 10 | int base_dir_len; |
| 11 | struct delayed_checkout *delayed_checkout; |
| 12 | struct checkout_metadata meta; |
| 13 | unsigned force:1, |
| 14 | quiet:1, |
| 15 | not_new:1, |
| 16 | clone:1, |
| 17 | refresh_cache:1; |
| 18 | }; |
| 19 | #define CHECKOUT_INIT { NULL, "" } |
| 20 | |
| 21 | #define TEMPORARY_FILENAME_LENGTH 25 |
| 22 | /* |
| 23 | * Write the contents from ce out to the working tree. |
| 24 | * |
| 25 | * When topath[] is not NULL, instead of writing to the working tree |
| 26 | * file named by ce, a temporary file is created by this function and |
| 27 | * its name is returned in topath[], which must be able to hold at |
| 28 | * least TEMPORARY_FILENAME_LENGTH bytes long. |
Matheus Tavares | ae22751 | 2021-03-23 11:19:36 -0300 | [diff] [blame] | 29 | * |
| 30 | * With checkout_entry_ca(), callers can optionally pass a preloaded |
| 31 | * conv_attrs struct (to avoid reloading it), when ce refers to a |
| 32 | * regular file. If ca is NULL, the attributes will be loaded |
| 33 | * internally when (and if) needed. |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 34 | */ |
Matheus Tavares | ae22751 | 2021-03-23 11:19:36 -0300 | [diff] [blame] | 35 | int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca, |
| 36 | const struct checkout *state, char *topath, |
| 37 | int *nr_checkouts); |
| 38 | static inline int checkout_entry(struct cache_entry *ce, |
| 39 | const struct checkout *state, char *topath, |
| 40 | int *nr_checkouts) |
| 41 | { |
| 42 | return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts); |
| 43 | } |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 44 | |
| 45 | void enable_delayed_checkout(struct checkout *state); |
| 46 | int finish_delayed_checkout(struct checkout *state, int *nr_checkouts); |
| 47 | |
| 48 | /* |
| 49 | * Unlink the last component and schedule the leading directories for |
| 50 | * removal, such that empty directories get removed. |
| 51 | */ |
| 52 | void unlink_entry(const struct cache_entry *ce); |
| 53 | |
Matheus Tavares | 49cfd90 | 2021-03-23 11:19:33 -0300 | [diff] [blame] | 54 | void *read_blob_entry(const struct cache_entry *ce, unsigned long *size); |
| 55 | int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st); |
Matheus Tavares | 584a0d1 | 2021-03-23 11:19:34 -0300 | [diff] [blame] | 56 | void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, |
| 57 | struct stat *st); |
Matheus Tavares | 49cfd90 | 2021-03-23 11:19:33 -0300 | [diff] [blame] | 58 | |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 59 | #endif /* ENTRY_H */ |