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

Re: How to get a directory filled with v2.6.11?

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 13, 2005, 04:37 UTC
Message-ID
<Pine.LNX.4.58.0507122116280.17536@g5.osdl.org>
In-Reply-To
<20050712050347.GA10751@buici.com>
On Mon, 11 Jul 2005, Marc Singer wrote:
Show 14 quoted lines
>
> I switched to using the git version in source control.
> Checkout/branching works great.  :-)
> 
> But, this version of git doesn't let me do
> 
>   # git checkout -f v2.6.11
>   error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a commit
>   Needed a single revision
> 
> which I suspect is protection added to prevent my special sort of
> shenanigans.  If I cannot perform the checkout anymore, is there
> another way to fill a directory with the contents of that particular
> tree?
Yes. Multiple ways. 
You can
 - just force that tree to be checked out:
	git-read-tree -m v2.6.11
	git-checkout-cache -f -u -a
   this basically gets you the state at the time of v2.6.11, but you still 
   don't have a _commit_ yet, so you'd have nothing to start actual 
   development from. BE CAREFUL! Your "HEAD" is now pointing to something 
   else than what you have checked out, so the next thing you want to do 
   is fix that up.
 - now, you can commit that as a _parentless_ commit (ie an "Initial
   commit") on a new branch, with something like this:
	echo "Linux 2.6.11" | git-commit-tree $(git-write-tree) > .git/refs/heads/my-branch
	ln -sf .git/HEAD refs/heads/my-branch
   and off you go. The above just creates a commit of the tree (which is 
   the v2.6.11 tree, since you did a "git-read-tree" on it), and uses the
   commit message "Linux 2.6.11"). It gives it no parents, and writes the
   result to the "my-branch" thing. It then makes HEAD point to that 
   branch, which completes the thing, and now your tree is in a consistent 
   state (ie HEAD matches what you have checked out, which matches 
   v2.6.11)
That's one way.

You can do it sneakier too, if you want to, and create the branch first. In particular, you can do

	git-cat-file tag v2.6.11
which will print out that tag, which starts with:
	object c39ae07f393806ccf406ef966e9a15afc43cc36a
	type tree
	tag v2.6.11-tree
	...

and now you can just do use that tree directly, without even reading it in:

	head=$(echo "Linux 2.6.11" | git-commit-tree c39ae07f393806ccf406ef966e9a15afc43cc36a)
	echo $head > .git/refs/heads/my-branch
which will give you the new branch.
Now you can just do
	git checkout my-branch
and you'll be there.

That said, whatever you do you will eventually end up with a series of commits that are not related to the "normal" commits in the 2.6.12-rc2+ chain, and since they don't have a common point, git won't be able to merge them for you. Git will be able to _track_ them for you, but at some point you'll want to probably try to move them forward to the "rest" of the git history.

And I'll warn you that that is not going to be entirely trivial, although Junio's "cherrypick" scripts should be useful as a way to automate it at least to some degree. This is why it would be so much easier if you could have started with a 2.6.12-rc2 or other "real" commit ;)

			Linus
Previous: Matthias UrlichsNext: Junio C Hamano
Message 3 of 5 in “How to get a directory filled with v2.6.11?”
  1. Marc SingerJul 12, 2005
  2. Matthias UrlichsJul 12, 2005
  3. Linus TorvaldsJul 13, 2005
  4. Junio C HamanoJul 13, 2005
  5. Linus TorvaldsJul 13, 2005

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.