git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 5 in “Extend index to save more flags”
  1. Extend index to save more flagsNguyễn Thái Ngọc Duy, Sep 1, 2008
  2. Johannes SixtSep 1, 2008
  3. Extend index to save more flagsNguyễn Thái Ngọc Duy, Sep 1, 2008
  4. Junio C HamanoSep 2, 2008
  5. Nguyen Thai Ngoc DuySep 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.