FetchOperation implements Callable<RevCommit, IOException> { public RevCommit call() throws IOException { FetchCommand fetch = Git.wrap(gitRepo).fetch(); fetch.setRemote(repo.getUri()); fetch.setRefSpecs(new RefSpec(repo.getBranch())); if (monitor != null) fetch.setProgressMonitor(monitor); try { fetch.call(); return CommitUtils.getRef(gitRepo, Constants.FETCH_HEAD); } catch (GitException e) { throw new IOException(e); } catch (JGitInternalException e) { throw new IOException(e); } catch (InvalidRemoteException e) { throw new IOException(e); } } FetchOperation(BuildRepository repo, Repository gitRepo);  FetchOperation(BuildRepository repo, Repository gitRepo,
			StreamProgressMonitor monitor); RevCommit call();  }
@Test public void fetchSingleCommit() throws Exception { git.add("file.txt", "a"); File dir = git.tempDirectory(); BuildRepository repo = new BuildRepository(git.repo().getDirectory() .toURI().toString(), Constants.R_HEADS + Constants.MASTER, null); CloneOperation clone = new CloneOperation(repo); Repository cloned = clone.invoke(dir, null); assertNotNull(cloned); RevCommit commit2 = git.add("file1.txt", "b"); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamProgressMonitor monitor = new StreamProgressMonitor( new PrintStream(out)); FetchOperation fetch = new FetchOperation(repo, cloned, monitor); RevCommit fetched = fetch.call(); assertEquals(commit2, fetched); assertTrue(out.toString().length() > 0); }