Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Best way to emulate "git checkout"?



On Mon, Aug 23, 2010 at 2:27 PM, Shawn O. Pearce <spearce@xxxxxxxxxxx> wrote:
We're still trying to move away from the deprecated code.  Not all
of it has been replaced... which is why for example Clone still
uses WorkDirCheckout.  We don't yet have the replacement done.  :-\

No worries - I'm hoping that I'll eventually end up comfortable enough with Jgit to be able to help out with some of that sort of work.
 
If you are always dropping into a clean directory, you can probably
get away with something like this.  Otherwise you'll need to use
WorkDirCheckout, even though its deprecated.

Yeah, I'm checking out in an existing directory, at least in some cases...guess I'll go with the deprecated code for the time being, and I'll keep track of this for the future.

Repository.resolve() is your friend.  It will take a string and
return an ObjectId.  From that you can cast it down to a commit or
a tree, either by appending "^{commit}" or "^{tree}" to the input
string and making resolve() do the work for you, or by calling the
parseFoo method on your own RevWalk.

Swank - perfect. Thanks!

A. 

Back to the top