@matheusbsbs / matheus-bagliano / commits / 16ce2e4c8f
Fork 0

index: future proof for "extended" index entries

We do not have any more bits in the on-disk index flags word, but we would need to have more in the future. Use the last remaining bits as a signal to tell us that the index entry we are looking at is an extended one. Since we do not understand the extended format yet, we will just error out when we see it. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 16, 2008 at 23:02 UTC 16ce2e4c8f9664f8ec5ae2bffed34d093d83a4d3
2 files changed +5
cache.h
+1
@@ -126,6 +126,7 @@ struct cache_entry {
126
127 #define CE_NAMEMASK (0x0fff)
128 #define CE_STAGEMASK (0x3000)
129 +#define CE_EXTENDED (0x4000)
130 #define CE_VALID (0x8000)
131 #define CE_STAGESHIFT 12
132
read-cache.c
+4
@@ -1118,6 +1118,10 @@ static void convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_en
1118 ce->ce_size = ntohl(ondisk->size);
1119 /* On-disk flags are just 16 bits */
1120 ce->ce_flags = ntohs(ondisk->flags);
1121 +
1122 + /* For future extension: we do not understand this entry yet */
1123 + if (ce->ce_flags & CE_EXTENDED)
1124 + die("Unknown index entry format");
1125 hashcpy(ce->sha1, ondisk->sha1);
1126
1127 len = ce->ce_flags & CE_NAMEMASK;