Re: [PATCH 1/4] add generic, type aware object chain walker
- From
- Martin Koegler <mkoegler@auto.tuwien.ac.at>
- Date
- Feb 25, 2008, 07:52 UTC
- Message-ID
- <20080225075242.GD15761@auto.tuwien.ac.at>
- In-Reply-To
- <7vwsotmqq2.fsf@gitster.siamese.dyndns.org>
On Sun, Feb 24, 2008 at 11:37:25PM -0800, Junio C Hamano wrote:
Show 5 quoted lines
> mkoegler@auto.tuwien.ac.at (Martin Koegler) writes: > So I do not have objection to OBJ_ANY (but again, this kind of > thing needs to be explained in your commit log message), but > giving the token the same value as OBJ_BAD may not be such a > cool idea.
What about #define OBJ_BAD -2
Show 14 quoted lines
> After all, if the walker callback was told with
> OBJ_ANY that any type of object is Ok, it should still say
> "oops" if the given object said it actually is of type OBJ_BAD.
> E.g. in your [2/4] patch:
>
> +static int mark_object(struct object *obj, int type, void *data)
> +{
> + ...
> + if (type != OBJ_ANY && obj->type != type) {
> + objerror(parent, "wrong object type in link");
> + }
>
> if you use the above #define, a tagged object that has a bad
> type will pass this check unnoticed, won't it?No, it wouldn't, as object->type is never initialized to OBJ_BAD: $ grep "OBJ_BAD" *.c *.h cache.h: OBJ_BAD = -1,
mfg Martin Kögler