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

Re: [RFH] bug in unpack_trees

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 8, 2008, 22:25 UTC
Message-ID
<alpine.LFD.1.00.0803081417040.5896@woody.linux-foundation.org>
In-Reply-To
<20080304115940.GA5260@sigill.intra.peff.net>
On Tue, 4 Mar 2008, Jeff King wrote:
>
> I am tracking down a bug in unpack_trees, but I can't seem to find the
> exact problem; I'm hoping to get help from people who have touched this
> code a bit more than I have.

Ok, so I decided that I should now finally go back and look at the original bug-report that triggered my unpack-trees rewrite, now that it's in a form where I feel like I can actually look at the code and fix the problem..

But when I just tested the bug-report case that Jeff described, it seems that I fixed the bug just with my cleanup. The current git "master" branch gives the following (incorrect) output for Jeff's script:

	[torvalds@woody repo]$   diff -u index1 index2
	--- index1      2008-03-08 14:16:51.000000000 -0800
	+++ index2      2008-03-08 14:16:51.000000000 -0800
	@@ -1 +1,2 @@
	 df/file
	+new

and with all my patches it just magically works correctly and the "git reset" correctly reset the index.

So while I actually tried to be as careful as possible and do a minimal "convert to cleaner code" rather than actually fix the bug, it seems that just the cleanup actually did end up fixing it and there is nothing more to chase down.

I'd love to say that I know what the original bug was, but since I couldn't fix it in the first place because I couldn't read the original code, I can't really say what fixed it.

Jeff's test-script appended just for people who can't find the original message that started this all.

		Linus
---
  # make a repo
  mkdir repo && cd repo && git init
  # make a directory which will become a df conflict
  mkdir df
  echo content >df/file
  git add df/file
  git commit -m one
  # and save a copy of the index
  git ls-files >index1
  # now make a new commit that has the df conflict and
  # a newly added file
  rm -rf df
  echo content >df
  git add df
  echo content >new
  git add new
  git commit -m two
  # now this should put our index exactly back to 'one'
  git reset --hard HEAD^
  # but it doesn't
  git ls-files >index2
  diff -u index1 index2
Previous: Linus TorvaldsNext: Daniel Barkalow
Message 6 of 9 in “[RFH] bug in unpack_trees”
  1. Jeff KingMar 4, 2008
  2. Linus TorvaldsMar 4, 2008
  3. Daniel BarkalowMar 5, 2008
  4. Linus TorvaldsMar 5, 2008
  5. Linus TorvaldsMar 6, 2008
  6. Linus TorvaldsMar 8, 2008
  7. Daniel BarkalowMar 8, 2008
  8. Jeff KingMar 13, 2008
  9. John GoerzenMar 14, 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.