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

Re: [PATCH] fsck: remove redundant parse_tree() invocation

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 19, 2017, 23:25 UTC
Message-ID
<20170719232541.GA13924@aiede.mtv.corp.google.com>
In-Reply-To
<20170718222848.1453-1-jonathantanmy@google.com>
Hi,
Jonathan Tan wrote:
> If obj->type == OBJ_TREE, an invocation of fsck_walk() will invoke
> parse_tree() and return quickly if that returns nonzero, so it is of no
> use for traverse_one_object() to invoke parse_tree() in this situation
> before invoking fsck_walk(). Remove that code.

I like the diffstat. I'm trying to figure out what the old code was trying to do, since that will make it easier to understand this change.

fsck_walk_tree calls parse_tree, so why did we need to parse it in advance? Was it just about handling the error differently when it fails to parse?

It appears this code comes from https://public-inbox.org/git/20080214090013.GK24004@spearce.org/:

 +	if (parse_tree(item) < 0)
 +		return; /* error already displayed */
 +
 +	init_tree_desc(&desc, item->buffer, item->size);

At that point the parse_tree call was not redundant. Later it must have been amended and cleaned up to use fsck_walk.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks for cleaning up.
Previous: Jonathan Tan
Message 2 of 2 in “fsck: remove redundant parse_tree() invocation”
  1. fsck: remove redundant parse_tree() invocationJonathan Tan, Jul 18, 2017
  2. Jonathan NiederJul 19, 2017

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.