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

[PATCH 0/5] parse_commit cleanups

From
Jeff King <peff@peff.net>
Date
Oct 8, 2013, 13:48 UTC
Message-ID
<20131008134843.GA7530@sigill.intra.peff.net>
In-Reply-To
<20131006044856.GA12301@sigill.intra.peff.net>
On Sun, Oct 06, 2013 at 12:48:56AM -0400, Jeff King wrote:
Show 9 quoted lines
> Instead of a segfault, let's print an error message and die
> a little more gracefully.
> [...]
> ---
> Not a huge deal, since we are terminating the program either way. There
> are other places in the code with a bare parse_commit that could
> probably use the same treatment. I didn't investigate them, but they
> could easily build on the parse_commit_or_die here if somebody wants to
> follow up.

Here are some follow-up patches that go on top. The first two are noop cleanups. The third and fourth are not strictly noops, but are minor behavior changes that should be strict improvements.

There are a number of unchecked parse_commit calls whose fallout is more complicated. In many cases, we want to ignore an error (keeping in mind that parse_commit will already have printed a message to stderr) and keep going, in order to allow users to to get as much done as they can in a broken repository.

The fifth patch deals with one of these cases. There are 8 more unchecked calls after this series, some of which may want to die(), or may want to be left alone; I didn't investigate deeply.

There are also some cases where we do not die, but perhaps should. In general, I think it makes sense to let fetch-pack and rev-list work around broken history, but probably not things like blame, which would then provide subtly wrong answers. Still, I doubt it's a big deal in practice, since corrupted repositories are relatively rare (and the message to stderr does inform the user that something is wrong).

  [1/5]: assume parse_commit checks commit->object.parsed
  [2/5]: assume parse_commit checks for NULL commit
  [3/5]: use parse_commit_or_die instead of segfaulting
  [4/5]: use parse_commit_or_die instead of custom message
  [5/5]: checkout: do not die when leaving broken detached HEAD
-Peff
Next: Jeff King
Message 1 of 6 in “parse_commit cleanups”
  1. 0/5 parse_commit cleanupsJeff King, Oct 8, 2013
  2. 1/5 assume parse_commit checks commit->object.parsedJeff King, Oct 8, 2013
  3. 2/5 assume parse_commit checks for NULL commitJeff King, Oct 8, 2013
  4. 3/5 use parse_commit_or_die instead of segfaultingJeff King, Oct 8, 2013
  5. 4/5 use parse_commit_or_die instead of custom messageJeff King, Oct 8, 2013
  6. 5/5 checkout: do not die when leaving broken detached HEADJeff King, Oct 8, 2013

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.