2014-06-13 12:19:36 +00:00
|
|
|
#ifndef SPLIT_INDEX_H
|
|
|
|
#define SPLIT_INDEX_H
|
|
|
|
|
2023-04-22 20:17:20 +00:00
|
|
|
#include "hash-ll.h"
|
2018-05-02 00:25:43 +00:00
|
|
|
|
2014-06-13 12:19:36 +00:00
|
|
|
struct index_state;
|
|
|
|
struct strbuf;
|
split-index: the writing part
prepare_to_write_split_index() does the major work, classifying
deleted, updated and added entries. write_link_extension() then just
writes it down.
An observation is, deleting an entry, then adding it back is recorded
as "entry X is deleted, entry X is added", not "entry X is replaced".
This is simpler, with small overhead: a replaced entry is stored
without its path, a new entry is store with its path.
A note about unpack_trees() and the deduplication code inside
prepare_to_write_split_index(). Usually tracking updated/removed
entries via read-cache API is enough. unpack_trees() manipulates the
index in a different way: it throws the entire source index out,
builds up a new one, copying/duplicating entries (using dup_entry)
from the source index over if necessary, then returns the new index.
A naive solution would be marking the entire source index "deleted"
and add their duplicates as new. That could bring $GIT_DIR/index back
to the original size. So we try harder and memcmp() between the
original and the duplicate to see if it needs updating.
We could avoid memcmp() too, by avoiding duplicating the original
entry in dup_entry(). The performance gain this way is within noise
level and it complicates unpack-trees.c. So memcmp() is the preferred
way to deal with deduplication.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-13 12:19:40 +00:00
|
|
|
struct ewah_bitmap;
|
2014-06-13 12:19:36 +00:00
|
|
|
|
|
|
|
struct split_index {
|
2018-05-02 00:25:43 +00:00
|
|
|
struct object_id base_oid;
|
2014-06-13 12:19:36 +00:00
|
|
|
struct index_state *base;
|
split-index: the writing part
prepare_to_write_split_index() does the major work, classifying
deleted, updated and added entries. write_link_extension() then just
writes it down.
An observation is, deleting an entry, then adding it back is recorded
as "entry X is deleted, entry X is added", not "entry X is replaced".
This is simpler, with small overhead: a replaced entry is stored
without its path, a new entry is store with its path.
A note about unpack_trees() and the deduplication code inside
prepare_to_write_split_index(). Usually tracking updated/removed
entries via read-cache API is enough. unpack_trees() manipulates the
index in a different way: it throws the entire source index out,
builds up a new one, copying/duplicating entries (using dup_entry)
from the source index over if necessary, then returns the new index.
A naive solution would be marking the entire source index "deleted"
and add their duplicates as new. That could bring $GIT_DIR/index back
to the original size. So we try harder and memcmp() between the
original and the duplicate to see if it needs updating.
We could avoid memcmp() too, by avoiding duplicating the original
entry in dup_entry(). The performance gain this way is within noise
level and it complicates unpack-trees.c. So memcmp() is the preferred
way to deal with deduplication.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-13 12:19:40 +00:00
|
|
|
struct ewah_bitmap *delete_bitmap;
|
|
|
|
struct ewah_bitmap *replace_bitmap;
|
|
|
|
struct cache_entry **saved_cache;
|
2014-06-13 12:19:36 +00:00
|
|
|
unsigned int saved_cache_nr;
|
2014-06-13 12:19:41 +00:00
|
|
|
unsigned int nr_deletions;
|
|
|
|
unsigned int nr_replacements;
|
2014-06-13 12:19:36 +00:00
|
|
|
int refcount;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct split_index *init_split_index(struct index_state *istate);
|
2014-06-13 12:19:38 +00:00
|
|
|
void save_or_free_index_entry(struct index_state *istate, struct cache_entry *ce);
|
2014-06-13 12:19:39 +00:00
|
|
|
void replace_index_entry_in_base(struct index_state *istate,
|
|
|
|
struct cache_entry *old,
|
2018-02-14 18:59:48 +00:00
|
|
|
struct cache_entry *new_entry);
|
2014-06-13 12:19:36 +00:00
|
|
|
int read_link_extension(struct index_state *istate,
|
|
|
|
const void *data, unsigned long sz);
|
|
|
|
int write_link_extension(struct strbuf *sb,
|
|
|
|
struct index_state *istate);
|
|
|
|
void move_cache_to_base_index(struct index_state *istate);
|
|
|
|
void merge_base_index(struct index_state *istate);
|
|
|
|
void prepare_to_write_split_index(struct index_state *istate);
|
|
|
|
void finish_writing_split_index(struct index_state *istate);
|
|
|
|
void discard_split_index(struct index_state *istate);
|
2017-02-27 18:00:01 +00:00
|
|
|
void add_split_index(struct index_state *istate);
|
|
|
|
void remove_split_index(struct index_state *istate);
|
2014-06-13 12:19:36 +00:00
|
|
|
|
|
|
|
#endif
|