All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] Extend index to save more flags
Date: Mon, 01 Sep 2008 15:05:05 +0200	[thread overview]
Message-ID: <48BBE881.1050206@viscovery.net> (raw)
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?

> @@ -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

  reply	other threads:[~2008-09-01 13:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01 11:32 [PATCH] Extend index to save more flags Nguyễn Thái Ngọc Duy
2008-09-01 13:05 ` Johannes Sixt [this message]
2008-09-01 14:16   ` Nguyễn Thái Ngọc Duy
2008-09-02  7:25     ` Junio C Hamano
2008-09-02  7:33       ` Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48BBE881.1050206@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.