JGit Adding Files [message #903408] |
Thu, 23 August 2012 14:05 |
R J 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 |
Robin Rosenberg 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 |
Christian Halstrick Messages: 274 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
|
|
|
Powered by
FUDForum. Page generated in 0.02107 seconds