index: future proof for "extended" index entries
authorJunio C Hamano <gitster@pobox.com>
Sun, 17 Aug 2008 06:02:08 +0000 (23:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Aug 2008 07:22:45 +0000 (00:22 -0700)
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>
cache.h
read-cache.c
diff --git a/cache.h b/cache.h
index 2475de9fa837596303284157e08b3080d64351ee..7b5cc834ab5df95a9589fa83e0236806b9c77097 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -126,6 +126,7 @@ struct cache_entry {
 
 #define CE_NAMEMASK  (0x0fff)
 #define CE_STAGEMASK (0x3000)
+#define CE_EXTENDED  (0x4000)
 #define CE_VALID     (0x8000)
 #define CE_STAGESHIFT 12
 
index 2c03ec3069decb20f7557af4ac7dbe295f2dcf9c..f0ba2247980cc938cc3f821a18e3b328966c4e06 100644 (file)
@@ -1118,6 +1118,10 @@ static void convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_en
        ce->ce_size  = ntohl(ondisk->size);
        /* On-disk flags are just 16 bits */
        ce->ce_flags = ntohs(ondisk->flags);
+
+       /* For future extension: we do not understand this entry yet */
+       if (ce->ce_flags & CE_EXTENDED)
+               die("Unknown index entry format");
        hashcpy(ce->sha1, ondisk->sha1);
 
        len = ce->ce_flags & CE_NAMEMASK;