Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tototoshi/3120089 to your computer and use it in GitHub Desktop.
Save tototoshi/3120089 to your computer and use it in GitHub Desktop.
trouble with jgit & scala.collection.JavaConversions
// import scala.collection.JavaConversions._
scala> val git = new Git(new FileRepositoryBuilder().findGitDir(new java.io.File("/path/to/repos")).readEnvironment().build())
git: org.eclipse.jgit.api.Git = org.eclipse.jgit.api.Git@18ed36fb
scala> git.log.addPath("foo").call.head
res49: org.eclipse.jgit.revwalk.RevCommit = commit c4554d9f46de49e449242a2aa75d39874dc99498 1342332998 ----sp
scala> git.log.addPath("foo").call.headOption
res50: Option[org.eclipse.jgit.revwalk.RevCommit] = Some(commit d3107ef998b25d70f86f1a5d530c31c02507d59e 1342012813 ----sp)
scala> git.log.addPath("foo").call.toList.head
res51: org.eclipse.jgit.revwalk.RevCommit = commit c4554d9f46de49e449242a2aa75d39874dc99498 1342332998 ----sp
scala> git.log.addPath("foo").call.toList.headOption
res52: Option[org.eclipse.jgit.revwalk.RevCommit] = Some(commit c4554d9f46de49e449242a2aa75d39874dc99498 1342332998 ----sp)
scala> git.log.addPath("foo").call.toList
res53: List[org.eclipse.jgit.revwalk.RevCommit] = List(commit c4554d9f46de49e449242a2aa75d39874dc99498 1342332998 ----sp, commit d3107ef998b25d70f86f1a5d530c31c02507d59e 1342012813 ----sp)
// headOption fetches second element??
@xuwei-k
Copy link

xuwei-k commented Jul 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment