Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Checkout a list of files

 
Hello Chris,
 
- Do you plan to extend the API soon ?
 
- Can you recommend some examples that would show how to use DirCacheCheckout / TreeWalk ? I have no clue how to do that.
 
Thank you in advance,
 
CyMac 

 

From: Christian Halstrick <christian.halstrick@xxxxxxxxx>
To: Cyril Machetti <machetti.geo@xxxxxxxxx>
Cc: jgit-dev@xxxxxxxxxxx
Sent: Wed, April 27, 2011 8:55:21 AM
Subject: Re: [jgit-dev] Checkout a list of files

Hi,

checking out specific files is not yet in the API. I think we should
extend JGit here. The problem is that it is not only a problem of the
CheckoutCommand class but we are missing that feature even in the
low-level DirCacheCheckout.

What "git checkout -- x" will basically do is to write what you
currently have in the index for "x" to the workingtree. The static
method DirCacheCheckout.checkoutEntry() will help you doing that. If
you would run a TreeWalk (filtered to the pathes of all the files you
are interested in) over the index and the working tree you would get
all the data needed to call checkoutEntry afterwards. But: The
standard checkout does a lot of checks which would not be executed if
you do it that way: What is if the file "x" contains unstaged data
(you modified "x" and haven't added that to the index)? Should we
overwrite these changes silently? What is if myFile is a directory in
the filesystem. Should delete that directory first including all files
underneath it just to be able to create and write the file afterwards?

For now you would have to do all these checks on your own until we
teach DirCacheCheckout to checkout portions of the workingtree. Sorry,
I guess that's not a nice answer for you, but currently I don't have a
better solution.

Ciao
  Chris



On Wed, Apr 27, 2011 at 07:41, Cyril Machetti <machetti.geo@xxxxxxxxx> wrote:
> Hello all,
>
> As recommended on the EGit forum
> (http://www.eclipse.org/forums/index.php?t=rview&goto=667086#msg_667086), I
> post here my question:
>
> I'd like to execute the following GIT command with JGIT, but after a lot of
> googling, I didn't find any simple way to do it. Any help would be greatly
> appreciated !
>
> git checkout file1.txt file2.txt file3.txt
>
> Thanks in advance,
> CyMac
>
>
> _______________________________________________
> jgit-dev mailing list
> jgit-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jgit-dev
>
>

Back to the top