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

Re: Simple UI question...

From
Chris Lee <clee@kde.org>
Date
Jan 7, 2007, 11:21 UTC
Message-ID
<204011cb0701070321w18942a3w7fb4f7ecd26fc457@mail.gmail.com>
In-Reply-To
<20070107111305.GD10351@spearce.org>
On 1/7/07, Shawn O. Pearce <spearce@spearce.org> wrote:
Show 42 quoted lines
> Chris Lee <clee@kde.org> 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... :)

Show 14 quoted lines
> > 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"? :)

Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 4 of 9 in “Simple UI question...”
  1. Chris LeeJan 7, 2007
  2. Josef "Jeff" SipekJan 7, 2007
  3. Shawn O. PearceJan 7, 2007
  4. Chris LeeJan 7, 2007
  5. Shawn O. PearceJan 7, 2007
  6. Chris LeeJan 7, 2007
  7. Junio C HamanoJan 7, 2007
  8. Chris LeeJan 7, 2007
  9. Junio C HamanoJan 7, 2007

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.