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

Re: [PATCH 1/4] add generic, type aware object chain walker

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 25, 2008, 08:02 UTC
Message-ID
<7vmyppmpko.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080225075242.GD15761@auto.tuwien.ac.at>
mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:
> What about
> #define OBJ_BAD -2
You mean "#define OBJ_ANY -2"?
Show 18 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,

Don't you think that is too subtle? Don't you want to future proof your code?

Using the OBJ_ANY (which I'd agree is a good name) that is different from anything else that is already defined would be a good idea for that, I would think.

Previous: Martin KoeglerNext: Martin Koegler
Message 9 of 19 in “add generic, type aware object chain walker”
  1. 1/4 add generic, type aware object chain walkerMartin Koegler, Feb 24, 2008
  2. 2/4 builtin-fsck: move away from object-refsMartin Koegler, Feb 24, 2008
  3. 3/4 Remove unused object-ref codeMartin Koegler, Feb 24, 2008
  4. 4/4 builtin-fsck: reports missing parent commitsMartin Koegler, Feb 24, 2008
  5. Shawn O. PearceFeb 25, 2008
  6. Martin KoeglerFeb 25, 2008
  7. Junio C HamanoFeb 25, 2008
  8. Martin KoeglerFeb 25, 2008
  9. Junio C HamanoFeb 25, 2008
  10. Martin KoeglerFeb 25, 2008
  11. Shawn O. PearceFeb 25, 2008
  12. Nicolas PitreFeb 25, 2008
  13. Shawn O. PearceFeb 25, 2008
  14. Nicolas PitreFeb 25, 2008
  15. Junio C HamanoFeb 25, 2008
  16. Martin KoeglerFeb 25, 2008
  17. Junio C HamanoFeb 25, 2008
  18. Martin KoeglerFeb 25, 2008
  19. Shawn O. PearceFeb 25, 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.