Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGit Client API

Hi,

Today I was again searching for a good place in jgit where I could put
a "commit" method which does exactly what the git.git commit command
does. As we know from this mail thread there is no obvious place where
I could put the implementation of git.git porcelain and plumbing
commands. So, here is my proposal which I'll push to gerrit if nobody
vetoes here:

Let's have a new package org.eclipse.jgit.api. In this package are two classes:

class GitPorcelain {
 public GitPorcelain(Repository db);
 ...
 public Commit commit(String message, boolean amend, boolean all,
PersonIdent commiter, PersonIdent author, .... more options ...);
 public DirCacheEntry add(String path, .... more options ...);
 public Iterable<RevCommit> log(boolean all, .... more options ...);
 ...
}

class GitPlumbing{
 public GitPlumbing(Repository db);

 public readTree(Treeish tree1, Treeish tree2, ... more options ...);
 ...
}

This would be a good place for egit, jgit/pgm package, external tools
to find entry-points into git. For jgit-newbies this would be a good
place to lookup how certain well known git.git commands can be
implemented with jgit.I am sure that people will always find good
reasons why not use this API (performance, not the correct set of
options, ...)

One question is not clear to me I would be glad about feedback:

How do we express in Java methods with a huge number of optional parameters?
Alternatives I see are
- lot of methods with the same name with all combination's of
parameters: commit(msg), commit(msg, amend), commit(msg, author) ...
- introduction of classes representing the options of a git.git
command: commit(CommitOptions opt) where CommitOptions has setter for
msg, author, committer, amend,

Ciao
 Chris


Back to the top