dir.c: always copy input to add_pattern()
[git.git] / entry.h
blobca3ed35bc08654ee47bc6c9331c1fad2804bfd32
1 #ifndef ENTRY_H
2 #define ENTRY_H
4 #include "convert.h"
6 struct cache_entry;
7 struct index_state;
9 struct checkout {
10 struct index_state *istate;
11 const char *base_dir;
12 int base_dir_len;
13 const char *super_prefix;
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;
22 #define CHECKOUT_INIT { .base_dir = "" }
24 #define TEMPORARY_FILENAME_LENGTH 25
26 * Write the contents from ce out to the working tree.
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.
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.
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)
45 return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts);
48 void enable_delayed_checkout(struct checkout *state);
49 int finish_delayed_checkout(struct checkout *state, int show_progress);
52 * Unlink the last component and schedule the leading directories for
53 * removal, such that empty directories get removed.
55 * The "super_prefix" is either NULL, or the "--super-prefix" passed
56 * down from "read-tree" et al.
58 void unlink_entry(const struct cache_entry *ce, const char *super_prefix);
60 void *read_blob_entry(const struct cache_entry *ce, size_t *size);
61 int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st);
62 void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
63 struct stat *st);
66 * Calls the correct function out of {unlink,rmdir}_or_warn based on
67 * the supplied file mode.
69 int remove_or_warn(unsigned int mode, const char *path);
71 #endif /* ENTRY_H */