On Mon, 11 Jul 2005, Marc Singer wrote:
>
> 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to