org.eclipse.jgit.api
Class LogCommand

java.lang.Object
  extended by org.eclipse.jgit.api.GitCommand<Iterable<RevCommit>>
      extended by org.eclipse.jgit.api.LogCommand
All Implemented Interfaces:
Callable<Iterable<RevCommit>>

public class LogCommand
extends GitCommand<Iterable<RevCommit>>

A class used to execute a Log command. It has setters for all supported options and arguments of this command and a call() method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call to call())

This is currently a very basic implementation which takes only one starting revision as option. TODO: add more options (revision ranges, sorting, ...)

See Also:
Git documentation about Log

Field Summary
 
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
 
Constructor Summary
protected LogCommand(Repository repo)
           
 
Method Summary
 LogCommand add(AnyObjectId start)
          Mark a commit to start graph traversal from.
 LogCommand addPath(String path)
          Show only commits that affect any of the specified paths.
 LogCommand addRange(AnyObjectId since, AnyObjectId until)
          Adds the range since..until
 Iterable<RevCommit> call()
          Executes the Log command with all the options and parameters collected by the setter methods (e.g.
 LogCommand not(AnyObjectId start)
          Same as --not start, or ^start
 
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogCommand

protected LogCommand(Repository repo)
Parameters:
repo -
Method Detail

call

public Iterable<RevCommit> call()
                         throws NoHeadException,
                                JGitInternalException
Executes the Log command with all the options and parameters collected by the setter methods (e.g. add(AnyObjectId), not(AnyObjectId), ..) of this class. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.

Returns:
an iteration over RevCommits
Throws:
NoHeadException
JGitInternalException

add

public LogCommand add(AnyObjectId start)
               throws MissingObjectException,
                      IncorrectObjectTypeException,
                      JGitInternalException
Mark a commit to start graph traversal from.

Parameters:
start -
Returns:
this
Throws:
MissingObjectException - the commit supplied is not available from the object database. This usually indicates the supplied commit is invalid, but the reference was constructed during an earlier invocation to RevWalk.lookupCommit(AnyObjectId).
IncorrectObjectTypeException - the object was not parsed yet and it was discovered during parsing that it is not actually a commit. This usually indicates the caller supplied a non-commit SHA-1 to RevWalk.lookupCommit(AnyObjectId).
JGitInternalException - a low-level exception of JGit has occurred. The original exception can be retrieved by calling Throwable.getCause(). Expect only IOException's to be wrapped. Subclasses of IOException (e.g. MissingObjectException) are typically not wrapped here but thrown as original exception
See Also:
RevWalk.markStart(RevCommit)

not

public LogCommand not(AnyObjectId start)
               throws MissingObjectException,
                      IncorrectObjectTypeException,
                      JGitInternalException
Same as --not start, or ^start

Parameters:
start -
Returns:
this
Throws:
MissingObjectException - the commit supplied is not available from the object database. This usually indicates the supplied commit is invalid, but the reference was constructed during an earlier invocation to RevWalk.lookupCommit(AnyObjectId).
IncorrectObjectTypeException - the object was not parsed yet and it was discovered during parsing that it is not actually a commit. This usually indicates the caller supplied a non-commit SHA-1 to RevWalk.lookupCommit(AnyObjectId).
JGitInternalException - a low-level exception of JGit has occurred. The original exception can be retrieved by calling Throwable.getCause(). Expect only IOException's to be wrapped. Subclasses of IOException (e.g. MissingObjectException) are typically not wrapped here but thrown as original exception

addRange

public LogCommand addRange(AnyObjectId since,
                           AnyObjectId until)
                    throws MissingObjectException,
                           IncorrectObjectTypeException,
                           JGitInternalException
Adds the range since..until

Parameters:
since -
until -
Returns:
this
Throws:
MissingObjectException - the commit supplied is not available from the object database. This usually indicates the supplied commit is invalid, but the reference was constructed during an earlier invocation to RevWalk.lookupCommit(AnyObjectId).
IncorrectObjectTypeException - the object was not parsed yet and it was discovered during parsing that it is not actually a commit. This usually indicates the caller supplied a non-commit SHA-1 to RevWalk.lookupCommit(AnyObjectId).
JGitInternalException - a low-level exception of JGit has occurred. The original exception can be retrieved by calling Throwable.getCause(). Expect only IOException's to be wrapped. Subclasses of IOException (e.g. MissingObjectException) are typically not wrapped here but thrown as original exception

addPath

public LogCommand addPath(String path)
Show only commits that affect any of the specified paths. The path must either name a file or a directory exactly. Note that regex expressions or wildcards are not supported.

Parameters:
path - a path is relative to the top level of the repository
Returns:
this


Copyright © 2011. All Rights Reserved.