2021-03-23 22:19:32 +08:00
|
|
|
#ifndef ENTRY_H
|
|
|
|
#define ENTRY_H
|
|
|
|
|
|
|
|
#include "cache.h"
|
|
|
|
#include "convert.h"
|
|
|
|
|
|
|
|
struct checkout {
|
|
|
|
struct index_state *istate;
|
|
|
|
const char *base_dir;
|
|
|
|
int base_dir_len;
|
|
|
|
struct delayed_checkout *delayed_checkout;
|
|
|
|
struct checkout_metadata meta;
|
|
|
|
unsigned force:1,
|
|
|
|
quiet:1,
|
|
|
|
not_new:1,
|
|
|
|
clone:1,
|
|
|
|
refresh_cache:1;
|
|
|
|
};
|
2021-09-27 20:54:27 +08:00
|
|
|
#define CHECKOUT_INIT { .base_dir = "" }
|
2021-03-23 22:19:32 +08:00
|
|
|
|
|
|
|
#define TEMPORARY_FILENAME_LENGTH 25
|
|
|
|
/*
|
|
|
|
* Write the contents from ce out to the working tree.
|
|
|
|
*
|
|
|
|
* When topath[] is not NULL, instead of writing to the working tree
|
|
|
|
* file named by ce, a temporary file is created by this function and
|
|
|
|
* its name is returned in topath[], which must be able to hold at
|
|
|
|
* least TEMPORARY_FILENAME_LENGTH bytes long.
|
2021-03-23 22:19:36 +08:00
|
|
|
*
|
|
|
|
* With checkout_entry_ca(), callers can optionally pass a preloaded
|
|
|
|
* conv_attrs struct (to avoid reloading it), when ce refers to a
|
|
|
|
* regular file. If ca is NULL, the attributes will be loaded
|
|
|
|
* internally when (and if) needed.
|
2021-03-23 22:19:32 +08:00
|
|
|
*/
|
2021-03-23 22:19:36 +08:00
|
|
|
int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
|
|
|
|
const struct checkout *state, char *topath,
|
|
|
|
int *nr_checkouts);
|
|
|
|
static inline int checkout_entry(struct cache_entry *ce,
|
|
|
|
const struct checkout *state, char *topath,
|
|
|
|
int *nr_checkouts)
|
|
|
|
{
|
|
|
|
return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts);
|
|
|
|
}
|
2021-03-23 22:19:32 +08:00
|
|
|
|
|
|
|
void enable_delayed_checkout(struct checkout *state);
|
2022-07-14 19:49:12 +08:00
|
|
|
int finish_delayed_checkout(struct checkout *state, int show_progress);
|
2021-03-23 22:19:32 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Unlink the last component and schedule the leading directories for
|
|
|
|
* removal, such that empty directories get removed.
|
|
|
|
*/
|
|
|
|
void unlink_entry(const struct cache_entry *ce);
|
|
|
|
|
2021-11-02 23:46:08 +08:00
|
|
|
void *read_blob_entry(const struct cache_entry *ce, size_t *size);
|
2021-03-23 22:19:33 +08:00
|
|
|
int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st);
|
2021-03-23 22:19:34 +08:00
|
|
|
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
|
|
|
|
struct stat *st);
|
2021-03-23 22:19:33 +08:00
|
|
|
|
2021-03-23 22:19:32 +08:00
|
|
|
#endif /* ENTRY_H */
|