Code covered by the BSD License  

Highlights from
JGit4MATLAB

4.0

4.0 | 2 ratings Rate this file 19 Downloads (last 30 days) File Size: 94.5 KB File ID: #41348
image thumbnail

JGit4MATLAB

by

 

16 Apr 2013 (Updated )

JGit4MATLAB is a wrapper for JGit in MATLAB. It is meant to be used from the MATLAB command window.

| Watch this File

File Information
Description

JGit4MATLAB is a wrapper for JGit (http://www.eclipse.org/jgit/) in MATLAB. It is meant to be used in the MATLAB command window.

Installation:
Download the full zip-file from MATLAB Central File Exchange, extract anywhere on your MATLAB path and type jgit. This will download the latest version of org.eclipse.jgit and edit your Java class path file called javaclasspath.txt in the MATLAB preferences directory, making a copy called javaclasspath.txt.JGitSaved of javaclasspath.txt if it already exists.

After this you must restart MATLAB for the changes to your MATLAB Java static class path to take effect.

Create your ssh keys using putty gen and convert them to OpenSSH format. If you set a passphrase, save it in %HOME%\.jsch-userinfo using

>> jgit saveSSHpassphrase <passphrase>

You can set and get global gitconfig name and email using

>> jgit setUserInfo <name> <email@address>

Usage:
In general usage is the same as in Git. See http://git-scm.com/docs.

>> jgit <command> [<options>...] [<args>...] [--] [<args>...]

See all commands

>> jgit help

Get help for individual command

>> jgit help <command>

There are some built in aliases.
co = checkout, ci = commit, st = status, br = branch

Known issues:
There is no mergetool. When a conflict occurs on either pull or merge, the conflicting files will be saved as *.BASE, *.LOCAL, *.REMOTE and *.orig. Download Meld (https://code.google.com/p/meld-installer/) or P4Merge (http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools). Then use the *.BASE, *.LOCAL and *.REMOTE files to resolve the conflict and save the file using its name. As an alternative just use the Git conflict markers to resolve the conflict and save the file.

In order to mark the conflict as resolved, you must first add the file to the index. Then commit.

>> jgit add resolved-conflict-file1 ...
>> jgit commit

Unfortunately, you can not use the --all flag with commit to mark a conflict as resolved. This is a feature that I have not yet implemented issue #7 (see https://github.com/mikofski/JGit4MATLAB/issues/7).

Also there is no way to abort a merge without using the org.eclipse.jgit.api.Git reset command.

>> git = JGit.getGitAPI % get an instance of the JGit api
>> repo = git.getRepository % get an instance of the repository
>> state = repo.getRepositoryState % get the repository state
>> MERGING = org.eclipse.jgit.lib.RepositoryState.MERGING % an enumeration (a constant)
>> resetCMD = git.reset; % get a reset command object
>> HARD = javaMethod('valueOf','org.eclipse.jgit.api.ResetCommand$ResetType','HARD'); % a constant
>> if state.equals(MERGING),resetCMD.setMode(HARD).call,end % check if merging then abort

See issue #10 (https://github.com/mikofski/JGit4MATLAB/issues/10).

Documentation:
http://mikofski.github.io/JGit4MATLAB/

Report Bugs:
https://github.com/mikofski/JGit4MATLAB/issues

References:
http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/api/Git.html

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Other requirements Internet connection
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
06 Oct 2014 Mark Mikofski

**Quick Tip:** Use `>> jgit update` to download the latest version of JGit. The older version is archived in the folder called `older-versions/` and the file `version` is updated with the latest version number. Then restart MATLAB for the update to take effect.

22 Oct 2013 Mark Mikofski

Another interesting mergetool is DiffMerge (http://www.sourcegear.com/diffmerge/) it has a standalone executable - select download from menu at left then select the Windows zip file and download/extract, start sgdm.exe - Voila! It's also available for other platforms. Unfortunately they a freemium model that has a registration pop-up, so this may not be the best option. Do you use JGit4MATLAB? Do you have any mergetool suggestions?

22 Oct 2013 Mark Mikofski

fixed bug #21 (https://github.com/mikofski/JGit4MATLAB/issues/21), available at Github. Do you use JGit4MATLAB? What features are you missing? Have you found bugs? Report them at Github (https://github.com/mikofski/JGit4MATLAB/issues)

22 Oct 2013 Mark Mikofski

Another possible mergetool is WinMerge - http://winmerge.org/ - it also is available as standalone exe, select download tab and look for "binaries" and download/extract zip file. I actually like this one better, it has generate-patch and open conflicted file functions - wonder if it can interpret Git conflict markers? Do you use JGit4MATLAB? What mergetool(s) would you like to see integrated?

17 Oct 2013 Zoe  
10 Oct 2013 Mark Mikofski

This is version 0.6 (Falcon)
+ It allows (subset of) Git syntax to be used.

EX1: jgit add file1 file2

EX2: jgit commit -m 'enter msg in single quotes'

EX3: jgit pull

EX4: jgit push origin feature

+ Bugs fixes.
+ `javaclasspath.txt` is now in prefdir instead of userpath (thanks Volker).
+ Merge conflicts also output *.BASE, *.LOCAL, *.REMOTE and *.orig for use in merge tools such as meld and p4m.
+ Documentation is now at http://mikofski.github.io/JGit4MATLAB/.

Please submit bugs to https://github.com/mikofski/JGit4MATLAB.

Enjoy!
--Mark

28 Sep 2013 Mark Mikofski

Just wanted to post an update - I have made some major improvements to JGit4MATLAB. Now it can use SSH passphrases (or not), and can pull, push and fetch. I put utilities in to change or view global config and to save your passphrase. Still more to come! Also check out new website: http://mikofski.github.io/JGit4MATLAB/.

12 Jul 2013 Mark Mikofski

See the recent post on JGit and JGit4MATLAB @ http://undocumentedmatlab.com/blog/jgit-matlab-integration/

27 Jun 2013 Mark Mikofski

download the latest JGit 3.0.0.201306101825-r by using<br/>
>> JGit.downloadJGitJar('path\to\JGIT4MATLAB\@JGit\org.eclipse.jgit.jar')
<br/>
e.g.:<br/>
>> JGit.downloadJGitJar('@JGit\org.eclipse.jgit.jar')
<br/>
Version: 3.0.0.201306101825
<br/>
then restart matlab

29 May 2013 Mark Mikofski

Hi Muthu, Thanks for the comment. I have added a function, lowercase "jgit.m" one level up and in the same namespace as @JGit so you should be able to just use the command interface that you describe if you put the toplevel (JGit4MATLAB) on your path.

EG: if JGit4MATLAB is on your path, and this is your file structure:

JGit4MATLAB/
\__jgit.m
..\__@JGit/
...\__JGit.m
....\__status.m
.....\__etc. (other methods in class "@" folder)

then you should be able to call the functions without strings as in your examples:

>> jgit status
# On branch master
nothing to commit, working directory clean

>> jgit branch list
gitCheckout
* master

>> jgit checkout gitCheckout

>> jgit status
# On branch gitCheckout
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# jgit.misc
#
# no changes added to commit (use "git add" and/or "git commit -a")

Is this what you are talking about? If not let me know, and thanks again for your feedback!

BTW: the @folder issue was resolved in the 2013-05-28 update.

29 May 2013 Muthu Annamalai

MATLAB has nice feature of supporting both command and functional interface.
i.e. >> disp('hello-world')
%works as well as,
>> disp hello-world

You may want to improve the command interface to JGIT, since most of the arguments are strings, we don't need to call it explicitly that way.

23 May 2013 Mark Mikofski

Sorry, folks, I accidentally zipped this up wrong last time, skipping the @JGit folder which is kind of important. I've uploaded a new submission but in the meantime just unzip or copy the contents to a folder on your path called @JGit.

15 May 2013 Mark Mikofski

FYI:
All commands that deal with remotes and that require authentication, EG: CLONE, FETCH, PULL, PUSH, will *only* work
* with SSH
* with *no* passphrase
* with keys in the openSSH format
* with keys and known hosts in $HOME\.ssh

Obviously remotes that do not require authentication will work fine. EG: public, read-only and local repositories.

SSH is very easy to set up.
1. Download puttygen (Intel x86) from this site:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Disregard the "Intel x86" business, it doesn't matter what processor you have or whether your os is 64-bit or 32-bit. Puttygen is a very mature well establish application that is used by many other applications, for example all of the TortoiseXXX scm clients use Putty, Plink and Pageant
This is the actual download here: (click to download then click to install)
http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe
2. create a folder called .ssh in your %USERPROFILE%. On Windows 7 this is
C:\Users\<your account name>
and on xp it is
C:\Documents and Settings\<your account name>
You can do this in matlab.
>> mkdir(fullfile(getenv('userprofile'), '.ssh'))
3. create a key using puttygen, this is fairly self explantory, and kind of fun, but do *not* set a passphrase; leave those fields blank!
4. using puttygen, find the conversion menu tab and export the key in the openSSH format to the .ssh folder you created earlier.
5. now copy and paste your public key to your remote repositories (Github, Bitbucket, etc.) as needed. Jsch, which is the ssh client that JGit uses should now work out of the box.

Unfortunately using https isn't possible with JGit4MATLAB. Sorry. but hopefully you'll love the excitement of using ssh key pairs!

Updates
18 Apr 2013

remove .git file, add log.m function

18 Apr 2013

improve log function, add some help

23 Apr 2013

add init command, some more help, and also fix "typing JGit should install JGit 1st time" now it really does

24 Apr 2013

add clone and branch

06 May 2013

now with checkout

14 May 2013

add JGit.diff

28 May 2013

correct zip file, did not have @JGit, listed methods as functions, oops! Also add command line wrapper that lets user call commands and args separated by strings.

28 May 2013

jgit command line function has better handling of numbers and boolean/logicals

05 Jun 2013

add merge command, update to release 0.5, try new file structure

27 Sep 2013

SSH now works with passphrase! Update download site. Add push and fix many bugs.

30 Sep 2013

now with fetch and proper checks for new jar files, including UserInfoSshSessionFactory which lets you use passphrases with jgit.

10 Oct 2013

git commands are now parsed for jgit at the command line, ie you can type jgit log -10, or jgit checkout -- file.m

11 Oct 2013

abbreviate summary

14 Oct 2013

fix bugs in pull and push. push should output message, for example if push rejected. Pull should save conflicting files for merging if conflict arises. add info on known issues

Contact us