Coverage Report

Created: 2024-09-08 06:23

/src/git/read-cache-ll.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef READ_CACHE_LL_H
2
#define READ_CACHE_LL_H
3
4
#include "hash.h"
5
#include "hashmap.h"
6
#include "statinfo.h"
7
8
/*
9
 * Basic data structures for the directory cache
10
 */
11
12
#define CACHE_SIGNATURE 0x44495243  /* "DIRC" */
13
struct cache_header {
14
  uint32_t hdr_signature;
15
  uint32_t hdr_version;
16
  uint32_t hdr_entries;
17
};
18
19
0
#define INDEX_FORMAT_LB 2
20
0
#define INDEX_FORMAT_UB 4
21
22
struct cache_entry {
23
  struct hashmap_entry ent;
24
  struct stat_data ce_stat_data;
25
  unsigned int ce_mode;
26
  unsigned int ce_flags;
27
  unsigned int mem_pool_allocated;
28
  unsigned int ce_namelen;
29
  unsigned int index; /* for link extension */
30
  struct object_id oid;
31
  char name[FLEX_ARRAY]; /* more */
32
};
33
34
0
#define CE_STAGEMASK (0x3000)
35
0
#define CE_EXTENDED  (0x4000)
36
0
#define CE_VALID     (0x8000)
37
0
#define CE_STAGESHIFT 12
38
39
/*
40
 * Range 0xFFFF0FFF in ce_flags is divided into
41
 * two parts: in-memory flags and on-disk ones.
42
 * Flags in CE_EXTENDED_FLAGS will get saved on-disk
43
 * if you want to save a new flag, add it in
44
 * CE_EXTENDED_FLAGS
45
 *
46
 * In-memory only flags
47
 */
48
0
#define CE_UPDATE            (1 << 16)
49
0
#define CE_REMOVE            (1 << 17)
50
0
#define CE_UPTODATE          (1 << 18)
51
0
#define CE_ADDED             (1 << 19)
52
53
0
#define CE_HASHED            (1 << 20)
54
0
#define CE_FSMONITOR_VALID   (1 << 21)
55
0
#define CE_WT_REMOVE         (1 << 22) /* remove in work directory */
56
0
#define CE_CONFLICTED        (1 << 23)
57
58
0
#define CE_UNPACKED          (1 << 24)
59
0
#define CE_NEW_SKIP_WORKTREE (1 << 25)
60
61
/* used to temporarily mark paths matched by pathspecs */
62
0
#define CE_MATCHED           (1 << 26)
63
64
0
#define CE_UPDATE_IN_BASE    (1 << 27)
65
0
#define CE_STRIP_NAME        (1 << 28)
66
67
/*
68
 * Extended on-disk flags
69
 */
70
0
#define CE_INTENT_TO_ADD     (1 << 29)
71
0
#define CE_SKIP_WORKTREE     (1 << 30)
72
/* CE_EXTENDED2 is for future extension */
73
#define CE_EXTENDED2         (1U << 31)
74
75
0
#define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD | CE_SKIP_WORKTREE)
76
77
/*
78
 * Safeguard to avoid saving wrong flags:
79
 *  - CE_EXTENDED2 won't get saved until its semantic is known
80
 *  - Bits in 0x0000FFFF have been saved in ce_flags already
81
 *  - Bits in 0x003F0000 are currently in-memory flags
82
 */
83
#if CE_EXTENDED_FLAGS & 0x803FFFFF
84
#error "CE_EXTENDED_FLAGS out of range"
85
#endif
86
87
/* Forward structure decls */
88
struct pathspec;
89
struct tree;
90
91
/*
92
 * Copy the sha1 and stat state of a cache entry from one to
93
 * another. But we never change the name, or the hash state!
94
 */
95
static inline void copy_cache_entry(struct cache_entry *dst,
96
            const struct cache_entry *src)
97
0
{
98
0
  unsigned int state = dst->ce_flags & CE_HASHED;
99
0
  int mem_pool_allocated = dst->mem_pool_allocated;
100
101
  /* Don't copy hash chain and name */
102
0
  memcpy(&dst->ce_stat_data, &src->ce_stat_data,
103
0
      offsetof(struct cache_entry, name) -
104
0
      offsetof(struct cache_entry, ce_stat_data));
105
106
  /* Restore the hash state */
107
0
  dst->ce_flags = (dst->ce_flags & ~CE_HASHED) | state;
108
109
  /* Restore the mem_pool_allocated flag */
110
0
  dst->mem_pool_allocated = mem_pool_allocated;
111
0
}
Unexecuted instantiation: add.c:copy_cache_entry
Unexecuted instantiation: am.c:copy_cache_entry
Unexecuted instantiation: checkout--worker.c:copy_cache_entry
Unexecuted instantiation: checkout-index.c:copy_cache_entry
Unexecuted instantiation: checkout.c:copy_cache_entry
Unexecuted instantiation: clean.c:copy_cache_entry
Unexecuted instantiation: clone.c:copy_cache_entry
Unexecuted instantiation: commit.c:copy_cache_entry
Unexecuted instantiation: describe.c:copy_cache_entry
Unexecuted instantiation: diff-tree.c:copy_cache_entry
Unexecuted instantiation: diff.c:copy_cache_entry
Unexecuted instantiation: difftool.c:copy_cache_entry
Unexecuted instantiation: fsck.c:copy_cache_entry
Unexecuted instantiation: grep.c:copy_cache_entry
Unexecuted instantiation: ls-files.c:copy_cache_entry
Unexecuted instantiation: merge-index.c:copy_cache_entry
Unexecuted instantiation: merge.c:copy_cache_entry
Unexecuted instantiation: mv.c:copy_cache_entry
Unexecuted instantiation: pull.c:copy_cache_entry
Unexecuted instantiation: read-tree.c:copy_cache_entry
Unexecuted instantiation: rebase.c:copy_cache_entry
Unexecuted instantiation: reset.c:copy_cache_entry
Unexecuted instantiation: rev-parse.c:copy_cache_entry
Unexecuted instantiation: rm.c:copy_cache_entry
Unexecuted instantiation: sparse-checkout.c:copy_cache_entry
Unexecuted instantiation: stash.c:copy_cache_entry
Unexecuted instantiation: submodule--helper.c:copy_cache_entry
Unexecuted instantiation: update-index.c:copy_cache_entry
Unexecuted instantiation: worktree.c:copy_cache_entry
Unexecuted instantiation: git.c:copy_cache_entry
Unexecuted instantiation: add-interactive.c:copy_cache_entry
Unexecuted instantiation: add-patch.c:copy_cache_entry
Unexecuted instantiation: apply.c:copy_cache_entry
Unexecuted instantiation: archive.c:copy_cache_entry
Unexecuted instantiation: attr.c:copy_cache_entry
Unexecuted instantiation: blame.c:copy_cache_entry
Unexecuted instantiation: cache-tree.c:copy_cache_entry
Unexecuted instantiation: convert.c:copy_cache_entry
Unexecuted instantiation: diff-lib.c:copy_cache_entry
Unexecuted instantiation: dir.c:copy_cache_entry
Unexecuted instantiation: entry.c:copy_cache_entry
Unexecuted instantiation: fsmonitor.c:copy_cache_entry
Unexecuted instantiation: hash-lookup.c:copy_cache_entry
Unexecuted instantiation: merge-ort.c:copy_cache_entry
Unexecuted instantiation: merge-ort-wrappers.c:copy_cache_entry
Unexecuted instantiation: merge-recursive.c:copy_cache_entry
Unexecuted instantiation: name-hash.c:copy_cache_entry
Unexecuted instantiation: object-name.c:copy_cache_entry
Unexecuted instantiation: parallel-checkout.c:copy_cache_entry
Unexecuted instantiation: pathspec.c:copy_cache_entry
Unexecuted instantiation: preload-index.c:copy_cache_entry
Unexecuted instantiation: read-cache.c:copy_cache_entry
Unexecuted instantiation: repository.c:copy_cache_entry
Unexecuted instantiation: rerere.c:copy_cache_entry
Unexecuted instantiation: resolve-undo.c:copy_cache_entry
Unexecuted instantiation: revision.c:copy_cache_entry
Unexecuted instantiation: sequencer.c:copy_cache_entry
Unexecuted instantiation: sparse-index.c:copy_cache_entry
Unexecuted instantiation: split-index.c:copy_cache_entry
Unexecuted instantiation: submodule.c:copy_cache_entry
Unexecuted instantiation: unpack-trees.c:copy_cache_entry
Unexecuted instantiation: wt-status.c:copy_cache_entry
112
113
static inline unsigned create_ce_flags(unsigned stage)
114
0
{
115
0
  return (stage << CE_STAGESHIFT);
116
0
}
Unexecuted instantiation: add.c:create_ce_flags
Unexecuted instantiation: am.c:create_ce_flags
Unexecuted instantiation: checkout--worker.c:create_ce_flags
Unexecuted instantiation: checkout-index.c:create_ce_flags
Unexecuted instantiation: checkout.c:create_ce_flags
Unexecuted instantiation: clean.c:create_ce_flags
Unexecuted instantiation: clone.c:create_ce_flags
Unexecuted instantiation: commit.c:create_ce_flags
Unexecuted instantiation: describe.c:create_ce_flags
Unexecuted instantiation: diff-tree.c:create_ce_flags
Unexecuted instantiation: diff.c:create_ce_flags
Unexecuted instantiation: difftool.c:create_ce_flags
Unexecuted instantiation: fsck.c:create_ce_flags
Unexecuted instantiation: grep.c:create_ce_flags
Unexecuted instantiation: ls-files.c:create_ce_flags
Unexecuted instantiation: merge-index.c:create_ce_flags
Unexecuted instantiation: merge.c:create_ce_flags
Unexecuted instantiation: mv.c:create_ce_flags
Unexecuted instantiation: pull.c:create_ce_flags
Unexecuted instantiation: read-tree.c:create_ce_flags
Unexecuted instantiation: rebase.c:create_ce_flags
Unexecuted instantiation: reset.c:create_ce_flags
Unexecuted instantiation: rev-parse.c:create_ce_flags
Unexecuted instantiation: rm.c:create_ce_flags
Unexecuted instantiation: sparse-checkout.c:create_ce_flags
Unexecuted instantiation: stash.c:create_ce_flags
Unexecuted instantiation: submodule--helper.c:create_ce_flags
Unexecuted instantiation: update-index.c:create_ce_flags
Unexecuted instantiation: worktree.c:create_ce_flags
Unexecuted instantiation: git.c:create_ce_flags
Unexecuted instantiation: add-interactive.c:create_ce_flags
Unexecuted instantiation: add-patch.c:create_ce_flags
Unexecuted instantiation: apply.c:create_ce_flags
Unexecuted instantiation: archive.c:create_ce_flags
Unexecuted instantiation: attr.c:create_ce_flags
Unexecuted instantiation: blame.c:create_ce_flags
Unexecuted instantiation: cache-tree.c:create_ce_flags
Unexecuted instantiation: convert.c:create_ce_flags
Unexecuted instantiation: diff-lib.c:create_ce_flags
Unexecuted instantiation: dir.c:create_ce_flags
Unexecuted instantiation: entry.c:create_ce_flags
Unexecuted instantiation: fsmonitor.c:create_ce_flags
Unexecuted instantiation: hash-lookup.c:create_ce_flags
Unexecuted instantiation: merge-ort.c:create_ce_flags
Unexecuted instantiation: merge-ort-wrappers.c:create_ce_flags
Unexecuted instantiation: merge-recursive.c:create_ce_flags
Unexecuted instantiation: name-hash.c:create_ce_flags
Unexecuted instantiation: object-name.c:create_ce_flags
Unexecuted instantiation: parallel-checkout.c:create_ce_flags
Unexecuted instantiation: pathspec.c:create_ce_flags
Unexecuted instantiation: preload-index.c:create_ce_flags
Unexecuted instantiation: read-cache.c:create_ce_flags
Unexecuted instantiation: repository.c:create_ce_flags
Unexecuted instantiation: rerere.c:create_ce_flags
Unexecuted instantiation: resolve-undo.c:create_ce_flags
Unexecuted instantiation: revision.c:create_ce_flags
Unexecuted instantiation: sequencer.c:create_ce_flags
Unexecuted instantiation: sparse-index.c:create_ce_flags
Unexecuted instantiation: split-index.c:create_ce_flags
Unexecuted instantiation: submodule.c:create_ce_flags
Unexecuted instantiation: unpack-trees.c:create_ce_flags
Unexecuted instantiation: wt-status.c:create_ce_flags
117
118
0
#define ce_namelen(ce) ((ce)->ce_namelen)
119
0
#define ce_size(ce) cache_entry_size(ce_namelen(ce))
120
0
#define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
121
0
#define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
122
0
#define ce_skip_worktree(ce) ((ce)->ce_flags & CE_SKIP_WORKTREE)
123
0
#define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
124
0
#define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
125
126
0
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
127
128
0
#define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */
129
0
#define CE_ENTRY_CHANGED  (1 << 1)
130
0
#define CE_ENTRY_REMOVED  (1 << 2)
131
0
#define CE_ENTRY_ADDED    (1 << 3)
132
0
#define RESOLVE_UNDO_CHANGED  (1 << 4)
133
0
#define CACHE_TREE_CHANGED  (1 << 5)
134
0
#define SPLIT_INDEX_ORDERED (1 << 6)
135
0
#define UNTRACKED_CHANGED (1 << 7)
136
0
#define FSMONITOR_CHANGED (1 << 8)
137
138
struct split_index;
139
struct untracked_cache;
140
struct progress;
141
struct pattern_list;
142
143
enum sparse_index_mode {
144
  /*
145
   * There are no sparse directories in the index at all.
146
   *
147
   * Repositories that don't use cone-mode sparse-checkout will
148
   * always have their indexes in this mode.
149
   */
150
  INDEX_EXPANDED = 0,
151
152
  /*
153
   * The index has already been collapsed to sparse directories
154
   * whereever possible.
155
   */
156
  INDEX_COLLAPSED,
157
158
  /*
159
   * The sparse directories that exist are outside the
160
   * sparse-checkout boundary, but it is possible that some file
161
   * entries could collapse to sparse directory entries.
162
   */
163
  INDEX_PARTIALLY_SPARSE,
164
};
165
166
struct index_state {
167
  struct cache_entry **cache;
168
  unsigned int version;
169
  unsigned int cache_nr, cache_alloc, cache_changed;
170
  struct string_list *resolve_undo;
171
  struct cache_tree *cache_tree;
172
  struct split_index *split_index;
173
  struct cache_time timestamp;
174
  unsigned name_hash_initialized : 1,
175
     initialized : 1,
176
     drop_cache_tree : 1,
177
     updated_workdir : 1,
178
     updated_skipworktree : 1,
179
     fsmonitor_has_run_once : 1;
180
  enum sparse_index_mode sparse_index;
181
  struct hashmap name_hash;
182
  struct hashmap dir_hash;
183
  struct object_id oid;
184
  struct untracked_cache *untracked;
185
  char *fsmonitor_last_update;
186
  struct ewah_bitmap *fsmonitor_dirty;
187
  struct mem_pool *ce_mem_pool;
188
  struct progress *progress;
189
  struct repository *repo;
190
  struct pattern_list *sparse_checkout_patterns;
191
};
192
193
/**
194
 * A "struct index_state istate" must be initialized with
195
 * INDEX_STATE_INIT or the corresponding index_state_init().
196
 *
197
 * If the variable won't be used again, use release_index() to free()
198
 * its resources. If it needs to be used again use discard_index(),
199
 * which does the same thing, but will use use index_state_init() at
200
 * the end. The discard_index() will use its own "istate->repo" as the
201
 * "r" argument to index_state_init() in that case.
202
 */
203
766
#define INDEX_STATE_INIT(r) { \
204
766
  .repo = (r), \
205
766
}
206
void index_state_init(struct index_state *istate, struct repository *r);
207
void release_index(struct index_state *istate);
208
209
/* Cache entry creation and cleanup */
210
211
/*
212
 * Create cache_entry intended for use in the specified index. Caller
213
 * is responsible for discarding the cache_entry with
214
 * `discard_cache_entry`.
215
 */
216
struct cache_entry *make_cache_entry(struct index_state *istate,
217
             unsigned int mode,
218
             const struct object_id *oid,
219
             const char *path,
220
             int stage,
221
             unsigned int refresh_options);
222
223
struct cache_entry *make_empty_cache_entry(struct index_state *istate,
224
             size_t name_len);
225
226
/*
227
 * Create a cache_entry that is not intended to be added to an index. If
228
 * `ce_mem_pool` is not NULL, the entry is allocated within the given memory
229
 * pool. Caller is responsible for discarding "loose" entries with
230
 * `discard_cache_entry()` and the memory pool with
231
 * `mem_pool_discard(ce_mem_pool, should_validate_cache_entries())`.
232
 */
233
struct cache_entry *make_transient_cache_entry(unsigned int mode,
234
                 const struct object_id *oid,
235
                 const char *path,
236
                 int stage,
237
                 struct mem_pool *ce_mem_pool);
238
239
struct cache_entry *make_empty_transient_cache_entry(size_t len,
240
                 struct mem_pool *ce_mem_pool);
241
242
/*
243
 * Discard cache entry.
244
 */
245
void discard_cache_entry(struct cache_entry *ce);
246
247
/*
248
 * Check configuration if we should perform extra validation on cache
249
 * entries.
250
 */
251
int should_validate_cache_entries(void);
252
253
/*
254
 * Duplicate a cache_entry. Allocate memory for the new entry from a
255
 * memory_pool. Takes into account cache_entry fields that are meant
256
 * for managing the underlying memory allocation of the cache_entry.
257
 */
258
struct cache_entry *dup_cache_entry(const struct cache_entry *ce, struct index_state *istate);
259
260
/*
261
 * Validate the cache entries in the index.  This is an internal
262
 * consistency check that the cache_entry structs are allocated from
263
 * the expected memory pool.
264
 */
265
void validate_cache_entries(const struct index_state *istate);
266
267
/*
268
 * Bulk prefetch all missing cache entries that are not GITLINKs and that match
269
 * the given predicate. This function should only be called if
270
 * repo_has_promisor_remote() returns true.
271
 */
272
typedef int (*must_prefetch_predicate)(const struct cache_entry *);
273
void prefetch_cache_entries(const struct index_state *istate,
274
          must_prefetch_predicate must_prefetch);
275
276
/* Initialize and use the cache information */
277
struct lock_file;
278
int do_read_index(struct index_state *istate, const char *path,
279
      int must_exist); /* for testting only! */
280
int read_index_from(struct index_state *, const char *path,
281
        const char *gitdir);
282
int is_index_unborn(struct index_state *);
283
284
/* For use with `write_locked_index()`. */
285
0
#define COMMIT_LOCK   (1 << 0)
286
0
#define SKIP_IF_UNCHANGED (1 << 1)
287
288
/*
289
 * Write the index while holding an already-taken lock. Close the lock,
290
 * and if `COMMIT_LOCK` is given, commit it.
291
 *
292
 * Unless a split index is in use, write the index into the lockfile.
293
 *
294
 * With a split index, write the shared index to a temporary file,
295
 * adjust its permissions and rename it into place, then write the
296
 * split index to the lockfile. If the temporary file for the shared
297
 * index cannot be created, fall back to the behavior described in
298
 * the previous paragraph.
299
 *
300
 * With `COMMIT_LOCK`, the lock is always committed or rolled back.
301
 * Without it, the lock is closed, but neither committed nor rolled
302
 * back.
303
 *
304
 * If `SKIP_IF_UNCHANGED` is given and the index is unchanged, nothing
305
 * is written (and the lock is rolled back if `COMMIT_LOCK` is given).
306
 */
307
int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags);
308
309
void discard_index(struct index_state *);
310
void move_index_extensions(struct index_state *dst, struct index_state *src);
311
int unmerged_index(const struct index_state *);
312
313
/**
314
 * Returns 1 if istate differs from tree, 0 otherwise.  If tree is NULL,
315
 * compares istate to HEAD.  If tree is NULL and on an unborn branch,
316
 * returns 1 if there are entries in istate, 0 otherwise.  If an strbuf is
317
 * provided, the space-separated list of files that differ will be appended
318
 * to it.
319
 */
320
int repo_index_has_changes(struct repository *repo,
321
         struct tree *tree,
322
         struct strbuf *sb);
323
324
int verify_path(const char *path, unsigned mode);
325
int strcmp_offset(const char *s1, const char *s2, size_t *first_change);
326
327
/*
328
 * Searches for an entry defined by name and namelen in the given index.
329
 * If the return value is positive (including 0) it is the position of an
330
 * exact match. If the return value is negative, the negated value minus 1
331
 * is the position where the entry would be inserted.
332
 * Example: The current index consists of these files and its stages:
333
 *
334
 *   b#0, d#0, f#1, f#3
335
 *
336
 * index_name_pos(&index, "a", 1) -> -1
337
 * index_name_pos(&index, "b", 1) ->  0
338
 * index_name_pos(&index, "c", 1) -> -2
339
 * index_name_pos(&index, "d", 1) ->  1
340
 * index_name_pos(&index, "e", 1) -> -3
341
 * index_name_pos(&index, "f", 1) -> -3
342
 * index_name_pos(&index, "g", 1) -> -5
343
 */
344
int index_name_pos(struct index_state *, const char *name, int namelen);
345
346
/*
347
 * Like index_name_pos, returns the position of an entry of the given name in
348
 * the index if one exists, otherwise returns a negative value where the negated
349
 * value minus 1 is the position where the index entry would be inserted. Unlike
350
 * index_name_pos, however, a sparse index is not expanded to find an entry
351
 * inside a sparse directory.
352
 */
353
int index_name_pos_sparse(struct index_state *, const char *name, int namelen);
354
355
/*
356
 * Determines whether an entry with the given name exists within the
357
 * given index. The return value is 1 if an exact match is found, otherwise
358
 * it is 0. Note that, unlike index_name_pos, this function does not expand
359
 * the index if it is sparse. If an item exists within the full index but it
360
 * is contained within a sparse directory (and not in the sparse index), 0 is
361
 * returned.
362
 */
363
int index_entry_exists(struct index_state *, const char *name, int namelen);
364
365
/*
366
 * Some functions return the negative complement of an insert position when a
367
 * precise match was not found but a position was found where the entry would
368
 * need to be inserted. This helper protects that logic from any integer
369
 * underflow.
370
 */
371
static inline int index_pos_to_insert_pos(uintmax_t pos)
372
0
{
373
0
  if (pos > INT_MAX)
374
0
    die("overflow: -1 - %"PRIuMAX, pos);
375
0
  return -1 - (int)pos;
376
0
}
Unexecuted instantiation: add.c:index_pos_to_insert_pos
Unexecuted instantiation: am.c:index_pos_to_insert_pos
Unexecuted instantiation: checkout--worker.c:index_pos_to_insert_pos
Unexecuted instantiation: checkout-index.c:index_pos_to_insert_pos
Unexecuted instantiation: checkout.c:index_pos_to_insert_pos
Unexecuted instantiation: clean.c:index_pos_to_insert_pos
Unexecuted instantiation: clone.c:index_pos_to_insert_pos
Unexecuted instantiation: commit.c:index_pos_to_insert_pos
Unexecuted instantiation: describe.c:index_pos_to_insert_pos
Unexecuted instantiation: diff-tree.c:index_pos_to_insert_pos
Unexecuted instantiation: diff.c:index_pos_to_insert_pos
Unexecuted instantiation: difftool.c:index_pos_to_insert_pos
Unexecuted instantiation: fsck.c:index_pos_to_insert_pos
Unexecuted instantiation: grep.c:index_pos_to_insert_pos
Unexecuted instantiation: ls-files.c:index_pos_to_insert_pos
Unexecuted instantiation: merge-index.c:index_pos_to_insert_pos
Unexecuted instantiation: merge.c:index_pos_to_insert_pos
Unexecuted instantiation: mv.c:index_pos_to_insert_pos
Unexecuted instantiation: pull.c:index_pos_to_insert_pos
Unexecuted instantiation: read-tree.c:index_pos_to_insert_pos
Unexecuted instantiation: rebase.c:index_pos_to_insert_pos
Unexecuted instantiation: reset.c:index_pos_to_insert_pos
Unexecuted instantiation: rev-parse.c:index_pos_to_insert_pos
Unexecuted instantiation: rm.c:index_pos_to_insert_pos
Unexecuted instantiation: sparse-checkout.c:index_pos_to_insert_pos
Unexecuted instantiation: stash.c:index_pos_to_insert_pos
Unexecuted instantiation: submodule--helper.c:index_pos_to_insert_pos
Unexecuted instantiation: update-index.c:index_pos_to_insert_pos
Unexecuted instantiation: worktree.c:index_pos_to_insert_pos
Unexecuted instantiation: git.c:index_pos_to_insert_pos
Unexecuted instantiation: add-interactive.c:index_pos_to_insert_pos
Unexecuted instantiation: add-patch.c:index_pos_to_insert_pos
Unexecuted instantiation: apply.c:index_pos_to_insert_pos
Unexecuted instantiation: archive.c:index_pos_to_insert_pos
Unexecuted instantiation: attr.c:index_pos_to_insert_pos
Unexecuted instantiation: blame.c:index_pos_to_insert_pos
Unexecuted instantiation: cache-tree.c:index_pos_to_insert_pos
Unexecuted instantiation: convert.c:index_pos_to_insert_pos
Unexecuted instantiation: diff-lib.c:index_pos_to_insert_pos
Unexecuted instantiation: dir.c:index_pos_to_insert_pos
Unexecuted instantiation: entry.c:index_pos_to_insert_pos
Unexecuted instantiation: fsmonitor.c:index_pos_to_insert_pos
Unexecuted instantiation: hash-lookup.c:index_pos_to_insert_pos
Unexecuted instantiation: merge-ort.c:index_pos_to_insert_pos
Unexecuted instantiation: merge-ort-wrappers.c:index_pos_to_insert_pos
Unexecuted instantiation: merge-recursive.c:index_pos_to_insert_pos
Unexecuted instantiation: name-hash.c:index_pos_to_insert_pos
Unexecuted instantiation: object-name.c:index_pos_to_insert_pos
Unexecuted instantiation: parallel-checkout.c:index_pos_to_insert_pos
Unexecuted instantiation: pathspec.c:index_pos_to_insert_pos
Unexecuted instantiation: preload-index.c:index_pos_to_insert_pos
Unexecuted instantiation: read-cache.c:index_pos_to_insert_pos
Unexecuted instantiation: repository.c:index_pos_to_insert_pos
Unexecuted instantiation: rerere.c:index_pos_to_insert_pos
Unexecuted instantiation: resolve-undo.c:index_pos_to_insert_pos
Unexecuted instantiation: revision.c:index_pos_to_insert_pos
Unexecuted instantiation: sequencer.c:index_pos_to_insert_pos
Unexecuted instantiation: sparse-index.c:index_pos_to_insert_pos
Unexecuted instantiation: split-index.c:index_pos_to_insert_pos
Unexecuted instantiation: submodule.c:index_pos_to_insert_pos
Unexecuted instantiation: unpack-trees.c:index_pos_to_insert_pos
Unexecuted instantiation: wt-status.c:index_pos_to_insert_pos
377
378
0
#define ADD_CACHE_OK_TO_ADD 1    /* Ok to add */
379
0
#define ADD_CACHE_OK_TO_REPLACE 2  /* Ok to replace file/directory */
380
0
#define ADD_CACHE_SKIP_DFCHECK 4  /* Ok to skip DF conflict checks */
381
0
#define ADD_CACHE_JUST_APPEND 8    /* Append only */
382
0
#define ADD_CACHE_NEW_ONLY 16    /* Do not replace existing ones */
383
0
#define ADD_CACHE_KEEP_CACHE_TREE 32  /* Do not invalidate cache-tree */
384
0
#define ADD_CACHE_RENORMALIZE 64        /* Pass along HASH_RENORMALIZE */
385
int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
386
void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
387
388
/* Remove entry, return true if there are more entries to go. */
389
int remove_index_entry_at(struct index_state *, int pos);
390
391
void remove_marked_cache_entries(struct index_state *istate, int invalidate);
392
int remove_file_from_index(struct index_state *, const char *path);
393
0
#define ADD_CACHE_VERBOSE 1
394
0
#define ADD_CACHE_PRETEND 2
395
0
#define ADD_CACHE_IGNORE_ERRORS 4
396
0
#define ADD_CACHE_IGNORE_REMOVAL 8
397
0
#define ADD_CACHE_INTENT 16
398
/*
399
 * These two are used to add the contents of the file at path
400
 * to the index, marking the working tree up-to-date by storing
401
 * the cached stat info in the resulting cache entry.  A caller
402
 * that has already run lstat(2) on the path can call
403
 * add_to_index(), and all others can call add_file_to_index();
404
 * the latter will do necessary lstat(2) internally before
405
 * calling the former.
406
 */
407
int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
408
int add_file_to_index(struct index_state *, const char *path, int flags);
409
410
int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
411
int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
412
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
413
int index_name_is_other(struct index_state *, const char *, int);
414
void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);
415
416
/* do stat comparison even if CE_VALID is true */
417
0
#define CE_MATCH_IGNORE_VALID   01
418
/* do not check the contents but report dirty on racily-clean entries */
419
0
#define CE_MATCH_RACY_IS_DIRTY    02
420
/* do stat comparison even if CE_SKIP_WORKTREE is true */
421
0
#define CE_MATCH_IGNORE_SKIP_WORKTREE 04
422
/* ignore non-existent files during stat update  */
423
0
#define CE_MATCH_IGNORE_MISSING   0x08
424
/* enable stat refresh */
425
0
#define CE_MATCH_REFRESH    0x10
426
/* don't refresh_fsmonitor state or do stat comparison even if CE_FSMONITOR_VALID is true */
427
0
#define CE_MATCH_IGNORE_FSMONITOR 0X20
428
int is_racy_timestamp(const struct index_state *istate,
429
          const struct cache_entry *ce);
430
int has_racy_timestamp(struct index_state *istate);
431
int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
432
int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
433
434
int match_stat_data_racy(const struct index_state *istate,
435
       const struct stat_data *sd, struct stat *st);
436
437
void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st);
438
439
/*
440
 * Fill members of st by members of sd enough to convince match_stat()
441
 * to consider that they match.  It should be usable as a replacement
442
 * for lstat() for a tracked path that is known to be up-to-date via
443
 * some out-of-line means (like fsmonitor).
444
 */
445
int fake_lstat(const struct cache_entry *ce, struct stat *st);
446
447
0
#define REFRESH_REALLY                   (1 << 0) /* ignore_valid */
448
0
#define REFRESH_UNMERGED                 (1 << 1) /* allow unmerged */
449
0
#define REFRESH_QUIET                    (1 << 2) /* be quiet about it */
450
0
#define REFRESH_IGNORE_MISSING           (1 << 3) /* ignore non-existent */
451
0
#define REFRESH_IGNORE_SUBMODULES        (1 << 4) /* ignore submodules */
452
0
#define REFRESH_IN_PORCELAIN             (1 << 5) /* user friendly output, not "needs update" */
453
0
#define REFRESH_PROGRESS                 (1 << 6) /* show progress bar if stderr is tty */
454
0
#define REFRESH_IGNORE_SKIP_WORKTREE     (1 << 7) /* ignore skip_worktree entries */
455
int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg);
456
/*
457
 * Refresh the index and write it to disk.
458
 *
459
 * 'refresh_flags' is passed directly to 'refresh_index()', while
460
 * 'COMMIT_LOCK | write_flags' is passed to 'write_locked_index()', so
461
 * the lockfile is always either committed or rolled back.
462
 *
463
 * If 'gentle' is passed, errors locking the index are ignored.
464
 *
465
 * Return 1 if refreshing the index returns an error, -1 if writing
466
 * the index to disk fails, 0 on success.
467
 *
468
 * Note that if refreshing the index returns an error, we still write
469
 * out the index (unless locking fails).
470
 */
471
int repo_refresh_and_write_index(struct repository*, unsigned int refresh_flags, unsigned int write_flags, int gentle, const struct pathspec *, char *seen, const char *header_msg);
472
473
struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);
474
475
void set_alternate_index_output(const char *);
476
477
extern int verify_index_checksum;
478
extern int verify_ce_order;
479
480
int cmp_cache_name_compare(const void *a_, const void *b_);
481
482
int add_files_to_cache(struct repository *repo, const char *prefix,
483
           const struct pathspec *pathspec, char *ps_matched,
484
           int include_sparse, int flags);
485
486
void overlay_tree_on_index(struct index_state *istate,
487
         const char *tree_name, const char *prefix);
488
489
#endif /* READ_CACHE_LL_H */