Re: [PATCH] Extend index to save more flags
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Sep 1, 2008, 13:05 UTC
- Message-ID
- <48BBE881.1050206@viscovery.net>
- In-Reply-To
- <1220268758-29550-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy schrieb:
> +/* Extended flags in ondisk_cache_entry_extended */ > +#define CE_EXTENDED2 (0x80000000) > +#define CE_EXTENDED_MASK (CE_EXTENDED2)
Wouldn't it be better, from a maintainance point of view, to have
#define CE_EXTENDED_MASK 0xffff0000
right from the beginning?
Show 18 quoted lines
> @@ -1143,19 +1144,29 @@ static void convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_en
> /* 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;
> +
> + if (ce->ce_flags & CE_EXTENDED) {
> + struct ondisk_cache_entry_extended *ondisk2;
> + ondisk2 = (struct ondisk_cache_entry_extended *)ondisk;
> + ce->ce_flags |= (ntohs(ondisk2->flags2) << 16) & CE_EXTENDED_MASK;
> + /* For future extension: we do not understand the last bit yet */
> + if (ce->ce_flags & CE_EXTENDED2)
> + die("Unknown index entry format");At this point, we do not understand the CE_EXTENDED2 flag; but we do not understand any of the other 15 extended flags, either. So, you should error out if *any* of them is non-zero.
> + name = ondisk2->name; > + } > + else > + name = ondisk->name;
-- Hannes