From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
John Goerzen <jgoerzen@complete.org>
Subject: [RFH] bug in unpack_trees
Date: Tue, 4 Mar 2008 06:59:41 -0500 [thread overview]
Message-ID: <20080304115940.GA5260@sigill.intra.peff.net> (raw)
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.
You can see the problem with this script:
# 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
The 'new' file is still in the index, and it shouldn't be. It's actually
not git-reset to blame, but the "git read-tree -u --reset HEAD^" that it
calls. The problem reproduces with every version of git I tried, so I
suspect it is as old as unpack_trees.
As far as I can tell, the D/F conflict somehow gets the list merge out
of sync. In unpack_trees_rec, every cache entry we look up gets compared
to the first tree entry, but because we are out of sync, the tree entry
will always become the new "first" (it looks like this test is supposed
to be for processing foo/ before foo/bar, and shouldn't otherwise
trigger). Because "first" and "cache_name" don't match, we don't realize
we haven't found an entry missing from the tree, and we don't trigger
the removal code.
So where I need help is figuring out how the traversal is _supposed_ to
work. I.e., why does it get out of sync on the D/F case? I'm sure it's
probably a one-liner fix, but I just don't see it.
-Peff
next reply other threads:[~2008-03-04 12:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 11:59 Jeff King [this message]
2008-03-04 21:31 ` [RFH] bug in unpack_trees Linus Torvalds
2008-03-05 6:47 ` Daniel Barkalow
2008-03-05 15:56 ` Linus Torvalds
2008-03-06 0:35 ` Linus Torvalds
2008-03-08 22:25 ` Linus Torvalds
2008-03-08 22:36 ` Daniel Barkalow
2008-03-13 14:00 ` Jeff King
2008-03-14 14:09 ` John Goerzen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080304115940.GA5260@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jgoerzen@complete.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).