Re: Simple UI question...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/7/07, Shawn O. Pearce <spearce@xxxxxxxxxxx> wrote:
Chris Lee <clee@xxxxxxx> wrote:
> So I'm trying to figure out the best way to pull out a checkout of the
> entire tree as of a given revision ID. I have a whole bunch of
> revision IDs, and I'd like to know what the git equivalent of (say)
> the following is:
>
> svn co -r280600 file:///path/to/svn/repo
>
> For the sake of argument, let's say that r280600 imported as
> 07058310db903317faa300b93004a5a2e0fc2dcc into my git tree.
>
> How do I get a pristine checkout in my working copy of the entire tree
> as the repository saw it at 07058310db903317faa300b93004a5a2e0fc2dcc?

One way is:

  git archive \
    --format=tar \
    07058310db903317faa300b93004a5a2e0fc2dcc \
    | (mkdir ../export; cd ../export; tar xf -)

Would give you a new directory tree which is not related to any
Git repository, but which contains the exact set of files in 070583.
But that's probably not what you meant.

> Eric Anholt suggested 'git checkout -b temporary-branch-name
> $sha1sum';

Yes, that is usually the way you do this.  Unlike the archive trick
above the result will be in your current working directory and
will be associated with the current Git repository.  Further you
can modify this and commit changes if you need to.

> davej suggested 'git-read-tree $sha1sum &&
> git-checkout-index -a -f'

That's just cruel.  Its only part of the underlying operations that
git checkout is performing, and its trashing your current branch
by making HEAD no longer match the index.  And its very low-level.
And it doesn't really do a 2-way merge to fully update the working
directory.  Not the best way for a user to perform this action.
Forget davej ever suggested this.

Heh. He's going to kill me for continuing to drag his name throught he
mud. Anyway... :)

> but for some reason, neither of these
> commands seems to do exactly as I expect. davej's method seems to work
> for some revision IDs, but not for others, and the other method seems
> to work just about as well. (The problem I have seen is that, for some
> revisions, the only files I get in the working copy are the files that
> were changed in that commit; the rest of the files in the tree do not
> get checked out.)

The problem is davej's method doesn't take into account what the
current working directory actually has stored in it.  It does not
delete any files which should not appear in $sha1sum.  It also
overwrites more files than it needs to, as it overwrites everything
instead of just those files which actually differ between the
current working directory and $sha1sum.

What I've been doing is 'rm -rf *' from the working directory and
trying the commands out; I don't want any empty folders or anything.

Eric Anholt's version is the correct way to do it.  It is also very
fast as it only has to modify the files which actually differed.

Eric's shows the same problem - for some revision IDs, when I do a
checkout, I only get the files that were changed in that revision.

If Eric's version isn't always working then I'd have to suggest
that you exmaine the output of `git status` for switching to
some temporary branch based on $sha1sum.  Perhaps you have local
modifications which are carrying over in your working directory?

I assume 'removing everything in the working tree' counts as "local
modifications"? :)
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]