Re: Digging through old vendor code
- From
Jeff King <peff@peff.net>
- Date
- Jan 14, 2008, 12:08 UTC
- Message-ID
- <20080114120807.GB12723@coredump.intra.peff.net>
- In-Reply-To
- <20080113162806.13991.qmail@science.horizon.com>
On Sun, Jan 13, 2008 at 11:28:06AM -0500, linux@horizon.com wrote:
> Maybe a real git wizard will show me how to insert the index entries > directly without ever doing anything as pedestrian as extracting, hashing, > and then deleting the files, but it's still not that bad.
git-read-tree? Unfortunately it has no option to insert only a subset of the tree. But you can make do with git-ls-tree piped to git-update-index.
Using the script below, Jon's sample file seems to be
v2.6.15-rc6-81-g0b57ee9:drivers/serial/amba-pl010.c
and it runs in about 8 seconds on v2.6.13..v2.6.15. I think it might be more intuitive to just diff a temporary index against each tree, but I don't think there's a way to say "find copies harder, but use only this subset of files as the source" which makes it less efficient.
Jon, you might try playing around with different ranges. I get a different answer for v2.6.13..v2.6.16.
-- >8 -- SRC=drivers/serial
echo >&2 Cleaning up after old runs... rm -f tmpindex git branch -D tmpbranch
echo >&2 Creating giant source commit...
for i in `git rev-list v2.6.13..v2.6.15 -- $SRC`; do
git ls-tree -r $i -- $SRC |
# note the whitespace is a literal tab
sed "s, , $i/," |
GIT_INDEX_FILE=tmpindex git update-index --index-info
done
tree=`GIT_INDEX_FILE=tmpindex git write-tree`
commit=`echo source | git commit-tree $tree`
git update-ref refs/heads/tmpbranch $commitecho >&2 Creating updated index... GIT_INDEX_FILE=tmpindex git add candidate.c echo >&2 Diffing... GIT_INDEX_FILE=tmpindex git diff-index --cached -l0 -M1% -C1% --find-copies-harder tmpbranch
# now you should manually git-describe the winner