Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » JGit Adding Files
JGit Adding Files [message #903408] Thu, 23 August 2012 14:05 Go to next message
R J is currently offline R JFriend
Messages: 8
Registered: August 2012
Junior Member
Hi

According to Git, you need to phyically copy the file into Git in order to commit. Is there any way through the code for the AddCommand class that to put the file including the location, and it copies the file into Git from the location you specify?

I have looked, but couldn't find anything. I don't think there is, but wanted to confirm if you knew.

[Updated on: Thu, 23 August 2012 14:07]

Report message to a moderator

Re: JGit Adding Files [message #903495 is a reply to message #903408] Thu, 23 August 2012 22:49 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
R J skrev 2012-08-23 16.05:> Hi
>
> According to Git, you need to phyically copy the file into Git in order to commit. Is there any way through the code for the AddCommand class that to put the file including
> the location, and it copies it for you?
>
> I have looked, but couldn't find anything. I don't think there is, but wanted to confirm if you knew.

With the high level API, all files have to reside within the git repository.

The lower level API's can take data from anywhere, it doesn't even have to be
a file, but it requires more work. Look at the AddCommand implementation for
inspiration, especially it's use or a DirCacheEditor, DirCacheEntry and ObjectInserter.

-- robin
Re: JGit Adding Files [message #903541 is a reply to message #903495] Fri, 24 August 2012 08:27 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 113
Registered: July 2009
Senior Member
and be aware that there are several other high-level jgit commands which can't work properly if you don't have all the files collected in your working tree. E.g. how should the status command be able to tell you about the status (e.g. which files have been modified locally since the last commit) if jgit doesn't know anymore where your local files reside.

But if your only use case is to add some content which doesn't reside in your working tree - then robin's suggestion is perfect.


Ciao
Chris
Previous Topic:Missing "Multi-Pull"
Next Topic:EGit variables not set on selection in Repositories view
Goto Forum:
  


Current Time: Sun Nov 23 11:10:38 GMT 2014

Powered by FUDForum. Page generated in 0.01975 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software