Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » JGit Adding Files
JGit Adding Files [message #903408] Thu, 23 August 2012 10:05 Go to next message
Eclipse UserFriend
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 10:07] by Moderator

Re: JGit Adding Files [message #903495 is a reply to message #903408] Thu, 23 August 2012 18:49 Go to previous messageGo to next message
Eclipse UserFriend
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 04:27 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Missing "Multi-Pull"
Next Topic:EGit variables not set on selection in Repositories view
Goto Forum:
  


Current Time: Sat Jul 12 19:11:25 EDT 2025

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

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

Back to the top