Skip to content

Commit ce51bf0

Browse files
pcloudsgitster
authored andcommitted
read-cache: store in-memory flags in the first 12 bits of ce_flags
We're running out of room for in-memory flags. But since b60e188 (Strip namelen out of ce_flags into a ce_namelen field - 2012-07-11), we copy the namelen (first 12 bits) to ce_namelen field. So those bits are free to use. Just make sure we do not accidentally write any in-memory flags back. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 626f35c commit ce51bf0

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct cache_entry {
145145
#define CE_STAGESHIFT 12
146146

147147
/*
148-
* Range 0xFFFF0000 in ce_flags is divided into
148+
* Range 0xFFFF0FFF in ce_flags is divided into
149149
* two parts: in-memory flags and on-disk ones.
150150
* Flags in CE_EXTENDED_FLAGS will get saved on-disk
151151
* if you want to save a new flag, add it in

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ static char *copy_cache_entry_to_ondisk(struct ondisk_cache_entry *ondisk,
17021702
ondisk->size = htonl(ce->ce_stat_data.sd_size);
17031703
hashcpy(ondisk->sha1, ce->sha1);
17041704

1705-
flags = ce->ce_flags;
1705+
flags = ce->ce_flags & ~CE_NAMEMASK;
17061706
flags |= (ce_namelen(ce) >= CE_NAMEMASK ? CE_NAMEMASK : ce_namelen(ce));
17071707
ondisk->flags = htons(flags);
17081708
if (ce->ce_flags & CE_EXTENDED) {

0 commit comments

Comments
 (0)