зеркало из https://github.com/microsoft/git.git
sparse-index: add 'sdir' index extension
The index format does not currently allow for sparse directory entries. This violates some expectations that older versions of Git or third-party tools might not understand. We need an indicator inside the index file to warn these tools to not interact with a sparse index unless they are aware of sparse directory entries. Add a new _required_ index extension, 'sdir', that indicates that the index may contain sparse directory entries. This allows us to continue to use the differences in index formats 2, 3, and 4 before we create a new index version 5 in a later change. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
836e25c51b
Коммит
cd42415fb4
|
@ -392,3 +392,15 @@ The remaining data of each directory block is grouped by type:
|
|||
in this block of entries.
|
||||
|
||||
- 32-bit count of cache entries in this block
|
||||
|
||||
== Sparse Directory Entries
|
||||
|
||||
When using sparse-checkout in cone mode, some entire directories within
|
||||
the index can be summarized by pointing to a tree object instead of the
|
||||
entire expanded list of paths within that tree. An index containing such
|
||||
entries is a "sparse index". Index format versions 4 and less were not
|
||||
implemented with such entries in mind. Thus, for these versions, an
|
||||
index containing sparse directory entries will include this extension
|
||||
with signature { 's', 'd', 'i', 'r' }. Like the split-index extension,
|
||||
tools should avoid interacting with a sparse index unless they understand
|
||||
this extension.
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#define CACHE_EXT_FSMONITOR 0x46534D4E /* "FSMN" */
|
||||
#define CACHE_EXT_ENDOFINDEXENTRIES 0x454F4945 /* "EOIE" */
|
||||
#define CACHE_EXT_INDEXENTRYOFFSETTABLE 0x49454F54 /* "IEOT" */
|
||||
#define CACHE_EXT_SPARSE_DIRECTORIES 0x73646972 /* "sdir" */
|
||||
|
||||
/* changes that can be kept in $GIT_DIR/index (basically all extensions) */
|
||||
#define EXTMASK (RESOLVE_UNDO_CHANGED | CACHE_TREE_CHANGED | \
|
||||
|
@ -1763,6 +1764,10 @@ static int read_index_extension(struct index_state *istate,
|
|||
case CACHE_EXT_INDEXENTRYOFFSETTABLE:
|
||||
/* already handled in do_read_index() */
|
||||
break;
|
||||
case CACHE_EXT_SPARSE_DIRECTORIES:
|
||||
/* no content, only an indicator */
|
||||
istate->sparse_index = 1;
|
||||
break;
|
||||
default:
|
||||
if (*ext < 'A' || 'Z' < *ext)
|
||||
return error(_("index uses %.4s extension, which we do not understand"),
|
||||
|
@ -3020,6 +3025,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
|
|||
if (err)
|
||||
return -1;
|
||||
}
|
||||
if (istate->sparse_index) {
|
||||
if (write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_SPARSE_DIRECTORIES, 0) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* CACHE_EXT_ENDOFINDEXENTRIES must be written as the last entry before the SHA1
|
||||
|
|
Загрузка…
Ссылка в новой задаче