Equivalent of `git add -A` and `git show` in jGit [message #1002468] |
Fri, 18 January 2013 11:35  |
Eclipse User |
|
|
|
I'm looking for equivalent commands for `git add -A` and `git show` in jGit.
I know how to add a single file using this code:
git.add().addFilepattern(path).call();
However, I'm used to the command:
git add -A
Which basically adds all the files automatically.
-----------
Also, I want to retrieve a specific version of a file from Git repository. In git I use:
git show HEAD~1:file.txt
How can I achieve this in jGit?
Any help will be appreciated.
|
|
|
|
|
Re: Equivalent of `git add -A` and `git show` in jGit [message #1003888 is a reply to message #1002468] |
Tue, 22 January 2013 02:40  |
Eclipse User |
|
|
|
Alireza Noori skrev 2013-01-18 17.48:
> I'm looking for equivalent commands for `git add -A` and `git show` in jGit.
> I know how to add a single file using this code:
>
> git.add().addFilepattern(path).call();
>
> However, I'm used to the command:
>
> git add -A
"." will be interpreted as "all" files. But, I'd say that's a bug, at the defail
level. jgit add . will add all files in the working tree, even if you've cd'd to
a subdirectory. JGit is probably bad at considering the current directory in
general, so be careful. If you want to add everything at the top level, then "." is fine.
> Which basically adds all the files automatically.
>
> -----------
>
> Also, I want to retrieve a specific version of a file from Git repository. In git I use:
>
> git show HEAD~1:file.txt
>
> How can I achieve this in jGit?
See the org.eclipse.jgit.pgm.Show class. It uses Repository.resolve which will return the blob id, or you
could use TreeWalk.forPath(). The latter requires some more work. An example can be found in
org.eclipse.egit.ui.internal.decorators.GitDocument.
-- robin
|
|
|
Powered by
FUDForum. Page generated in 0.04402 seconds