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; |
Ævar Arnfjörð Bjarmason | 4002ec3 | 2022-12-20 13:39:56 +0100 | [diff] [blame] | 11 | const char *super_prefix; |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 12 | struct delayed_checkout *delayed_checkout; |
| 13 | struct checkout_metadata meta; |
| 14 | unsigned force:1, |
| 15 | quiet:1, |
| 16 | not_new:1, |
| 17 | clone:1, |
| 18 | refresh_cache:1; |
| 19 | }; |
Ævar Arnfjörð Bjarmason | f69a6e4 | 2021-09-27 14:54:27 +0200 | [diff] [blame] | 20 | #define CHECKOUT_INIT { .base_dir = "" } |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 21 | |
| 22 | #define TEMPORARY_FILENAME_LENGTH 25 |
| 23 | /* |
| 24 | * Write the contents from ce out to the working tree. |
| 25 | * |
| 26 | * When topath[] is not NULL, instead of writing to the working tree |
| 27 | * file named by ce, a temporary file is created by this function and |
| 28 | * its name is returned in topath[], which must be able to hold at |
| 29 | * least TEMPORARY_FILENAME_LENGTH bytes long. |
Matheus Tavares | ae22751 | 2021-03-23 11:19:36 -0300 | [diff] [blame] | 30 | * |
| 31 | * With checkout_entry_ca(), callers can optionally pass a preloaded |
| 32 | * conv_attrs struct (to avoid reloading it), when ce refers to a |
| 33 | * regular file. If ca is NULL, the attributes will be loaded |
| 34 | * internally when (and if) needed. |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 35 | */ |
Matheus Tavares | ae22751 | 2021-03-23 11:19:36 -0300 | [diff] [blame] | 36 | int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca, |
| 37 | const struct checkout *state, char *topath, |
| 38 | int *nr_checkouts); |
| 39 | static inline int checkout_entry(struct cache_entry *ce, |
| 40 | const struct checkout *state, char *topath, |
| 41 | int *nr_checkouts) |
| 42 | { |
| 43 | return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts); |
| 44 | } |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 45 | |
| 46 | void enable_delayed_checkout(struct checkout *state); |
Matheus Tavares | 611c778 | 2022-07-14 08:49:12 -0300 | [diff] [blame] | 47 | int finish_delayed_checkout(struct checkout *state, int show_progress); |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * Unlink the last component and schedule the leading directories for |
| 51 | * removal, such that empty directories get removed. |
Ævar Arnfjörð Bjarmason | 4002ec3 | 2022-12-20 13:39:56 +0100 | [diff] [blame] | 52 | * |
| 53 | * The "super_prefix" is either NULL, or the "--super-prefix" passed |
| 54 | * down from "read-tree" et al. |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 55 | */ |
Ævar Arnfjörð Bjarmason | 4002ec3 | 2022-12-20 13:39:56 +0100 | [diff] [blame] | 56 | void unlink_entry(const struct cache_entry *ce, const char *super_prefix); |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 57 | |
Matt Cooper | e9aa762 | 2021-11-02 15:46:08 +0000 | [diff] [blame] | 58 | void *read_blob_entry(const struct cache_entry *ce, size_t *size); |
Matheus Tavares | 49cfd90 | 2021-03-23 11:19:33 -0300 | [diff] [blame] | 59 | 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] | 60 | void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, |
| 61 | struct stat *st); |
Matheus Tavares | 49cfd90 | 2021-03-23 11:19:33 -0300 | [diff] [blame] | 62 | |
Matheus Tavares | d052cc0 | 2021-03-23 11:19:32 -0300 | [diff] [blame] | 63 | #endif /* ENTRY_H */ |