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

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 $commit

echo >&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
Previous: Jon SmirlNext: Jon Smirl
Message 4 of 5 in “Re: Digging through old vendor code”
  1. linux@horizon.comJan 13, 2008
  2. Jon SmirlJan 13, 2008
  3. Jon SmirlJan 13, 2008
  4. Jeff KingJan 14, 2008
  5. Jon SmirlJan 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.