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

Re: Identify Commit ID from an Extracted Source Snapshot

From
MSMichael Schubert <mschub@elegosoft.com>
Date
Feb 16, 2012, 23:43 UTC
Message-ID
<4F3D94A1.2040706@elegosoft.com>
In-Reply-To
<4F3D8EFF.9000806@vilain.net>
On 02/17/2012 12:19 AM, Sam Vilain wrote:
Show 32 quoted lines
> On 2/16/12 3:00 PM, Michael Schubert wrote:
>> On 02/16/2012 11:06 PM, James Walmsley wrote:
>>> I couldn't find this on google, and I have no idea if its even 
>>> possible. I have several zip files from previous versions of my 
>>> source code. (I imported svn into git). I would like to add TAGS
>>> to git which represent the versions based on the files in my zip 
>>> archives.
>>> 
>>> Does anyone know how to do this?
>> 
>> If it's just about providing the ancient code together with the 
>> (imported) more recent history from SVN, you could create an extra 
>> orphan branch for each zip packet, add the files, commit and 
>> eventually tag.
>> 
>> If your question is more like "how do I tell git to find out where 
>> this old code fits in my history and eventually place it there", 
>> the answer is: you cannot do it. No VCS will do this and
>> especially not Git.
> 
> Once you've got a tree in git which corresponds to the contents of
> the zip file, you can use git diff --stat TREEID COMMITID
> 
> You can get the commitid by obtaining the most recent timestamp for a
> file within the archive, then just using git rev-list --all
> --since=... --until=... to get a window of commit IDs, and hunt
> around until you find the one with the smallest diff.
> 
> It's hardly a straightforward thing, usually because the contents of
> the zip file never quite match the exact contents of source
> control—think autoconf and other files generated for distribution but
> not stored in the history.  So you need to use a fuzzy search.

I totally disregared the "slicing and rebuilding history approach", just because I didn't think that's what James is asking about. Could be fun.

Previous: Sam VilainNext: Jonathan Nieder
Message 4 of 6 in “Identify Commit ID from an Extracted Source Snapshot”
  1. James WalmsleyFeb 16, 2012
  2. Michael SchubertFeb 16, 2012
  3. Sam VilainFeb 16, 2012
  4. Michael SchubertFeb 16, 2012
  5. Jonathan NiederFeb 16, 2012
  6. Michael SchubertFeb 17, 2012

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.