split-index: strip pathname of on-disk replaced entries
We know the positions of replaced entries via the replace bitmap in "link" extension, so the "name" path does not have to be stored (it's still in the shared index). With this, we also have a way to distinguish additions vs replacements at load time and can catch broken "link" extensions. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
ce7c614bce
commit
b3c96fb158
10
read-cache.c
10
read-cache.c
@ -1787,9 +1787,15 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
|
||||
{
|
||||
int size;
|
||||
struct ondisk_cache_entry *ondisk;
|
||||
int saved_namelen = saved_namelen; /* compiler workaround */
|
||||
char *name;
|
||||
int result;
|
||||
|
||||
if (ce->ce_flags & CE_STRIP_NAME) {
|
||||
saved_namelen = ce_namelen(ce);
|
||||
ce->ce_namelen = 0;
|
||||
}
|
||||
|
||||
if (!previous_name) {
|
||||
size = ondisk_ce_size(ce);
|
||||
ondisk = xcalloc(1, size);
|
||||
@ -1821,6 +1827,10 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
|
||||
strbuf_splice(previous_name, common, to_remove,
|
||||
ce->name + common, ce_namelen(ce) - common);
|
||||
}
|
||||
if (ce->ce_flags & CE_STRIP_NAME) {
|
||||
ce->ce_namelen = saved_namelen;
|
||||
ce->ce_flags &= ~CE_STRIP_NAME;
|
||||
}
|
||||
|
||||
result = ce_write(c, fd, ondisk, size);
|
||||
free(ondisk);
|
||||
|
||||
Reference in New Issue
Block a user