Skip to contentSkip to conversation

How to get a directory filled with v2.6.11?

DISCUSSION Marc Singer 4 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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?

What am I doing? I've got some updates against 2.6.11 orphaned in another develpment directory. I could just upack a tar.bz2 file for 2.6.11, but git is more clever. I want to perform a diff against the tagged v2.6.11 and my development tree.

#1 lore raw
Quoted 6 lines · Marc Singer

I switched to using the git version in source control. Checkout/branching works great. :-)

But, this version of git doesn't let me do

Quoted 8 lines
  # 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

#2 lore raw
Quoted 11 lines · Linus Torvalds

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 ;)

I do not think git-cherry would be that useful in this context. Nobody upstream is merging things into your development trail, started at the private commit you made based on the 2.6.11 tree.

I was wondering if adding "graft trail" to merge-base command would help this situation.

    SYNOPSIS
    --------
    'git-merge-base' ( --graft <commit1> <commit2>)* <commit> <commit>

    ...

    OPTIONS
    -------
    <commit>::
            The two heads being merged.

    --graft <commit1> <commit2>::
            Treat as if <commit1> is one of the ancestors of
            <commit2> when computing the commit ancestry chain.
            Can be specified more than once.

Then we could say "--graft v2.6.11 v2.6.12-rc2".

We may want to have a configuration file in .git/ directory (I think it belongs to .git/objects/ hierarchy, because this is not per work-tree thing but per project thing) that record this "graft" relationship.

When we have not-so-stupid [*1*] merge algorithm in place, we could do even better. Starting from v2.6.11 tree, we can rebuild (from BKCVS) the development trail up to v2.6.12-rc2, which is independent from the current kernel development trail which started at (a different) v2.6.12-rc2. Use the former one as <commit1>, and the latter one as <commit2>, and the "clever" merge algorithm would be able to follow across the v2.6.12-rc2 discontiguity and trace the development back to v2.6.11.

[Footnote]

*1* <[email protected]>

So if you want to document that the current automatic merge is stupid, hey, go wild. It _is_ stupid. It's surprisingly effective, but that may be because of kernel development patterns and may not be true in other projects.

#3 lore raw
Quoted 4 lines · Junio C Hamano

I do not think git-cherry would be that useful in this context. Nobody upstream is merging things into your development trail, started at the private commit you made based on the 2.6.11 tree.

No, the point being that he (or anybody else) could move the commits as patches, one by one, from his 2.6.11 base to whatever later base that _is_ in the commit history.

It's really the same issue as with cherry-picking: you do commits one at a time as diffs, see if that diff already exists in the destination stream, and if not, you try to apply it as a patch and re-commit it with the old commit message in a new place in history.

Linus

#4 lore raw
In reply to Marc Singer
Quoted 1 line · Marc Singer

v2.6.11, 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c

You can create your own parent-less commit for that tree. (It's what I did...)

Signature · 7 lines
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  [email protected]
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
"It was the most earnest ambition I ever had....Not that I ever
 really wanted to be a preacher, but because it never occurred to
 me that a preacher could be damned. It looked like a safe job."
               [Mark Twain, a Biography]