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

Re: [BUG] index corruption with git commit -p

From
Jeff King <peff@peff.net>
Date
Sep 2, 2018, 08:02 UTC
Message-ID
<20180902080205.GD18787@sigill.intra.peff.net>
In-Reply-To
<20180902075351.lkfnekklnwot7lzf@ltop.local>
On Sun, Sep 02, 2018 at 09:53:53AM +0200, Luc Van Oostenryck wrote:
Show 16 quoted lines
> > At any rate, I think this perfectly explains the behavior we're seeing.
> 
> Yes, this certainly make sense.
> 
> For fun (and testing) I tried to take the problem in the other direction:
> * why hasn't this be detected earlier (I'm reasonably be sure I did the
>   same operation a few times already without seeing the corruption)?
> * how easy it is to reproduce the problem?
> * Is it enough to do an interactive commit with nothing needing interactive?
> 
> So I tried the following and some variants:
>   > for i in $(seq -w 0 100); do echo $i > f$i; done
>   > git add f* && git commit -m add f* && git rm -q f* && git commit -m rm -p
> 
> but I didn't succeed to recreate the problem. So I'm still wondering
> what is special in my repository & tree that trigger the corruption.

I think the partial deletion is important, because it means that the resulting index is going to be smaller. And the truncation problem only matters when we go from a larger file to a smaller one (since otherwise overwrite the old content completely).

And it doesn't seem to trigger without the interactive "-p". I think that's not directly related, but it somehow triggers the case where we actually need to update the cache tree in this particular order.

That's pretty hand-wavy, but I think it gives a sense of why most people didn't run into this. I do wish I understood better what it would take to create a minimal example for the test suite.

-Peff
Previous: Luc Van OostenryckNext: Junio C Hamano
Message 7 of 19 in “[BUG] index corruption with git commit -p”
  1. Luc Van OostenryckSep 1, 2018
  2. Ævar Arnfjörð BjarmasonSep 1, 2018
  3. Jeff KingSep 2, 2018
  4. Duy NguyenSep 2, 2018
  5. Jeff KingSep 2, 2018
  6. Luc Van OostenryckSep 2, 2018
  7. Jeff KingSep 2, 2018
  8. Junio C HamanoSep 4, 2018
  9. Duy NguyenSep 4, 2018
  10. Jeff KingSep 4, 2018
  11. reopen_tempfile(): truncate opened fileJeff King, Sep 4, 2018
  12. Duy NguyenSep 5, 2018
  13. Jeff KingSep 5, 2018
  14. Duy NguyenSep 5, 2018
  15. Jeff KingSep 5, 2018
  16. Junio C HamanoSep 5, 2018
  17. Jeff KingSep 5, 2018
  18. Junio C HamanoSep 5, 2018
  19. Luc Van OostenryckSep 5, 2018

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.