org.netbeans.libs.git/1 1.1

org.netbeans.libs.git
Class GitClient

java.lang.Object
  extended by org.netbeans.libs.git.GitClient

public final class GitClient
extends Object

This class provides access to all supported git commands, methods that allow you to get information about a git repository or affect the behavior of invoked commands.
An instance of this class is always bound to a local git repository. The repository (identified by a git repository root file) may not exist on disk however because obviously when cloning or initializing a repository it may not yet physically exist.

Working with this class
A client of the API should follow these steps in order to run a certain git commands:
  1. Acquire an instance of a git client

    Instances of a git client are provided by GitRepository. To get one call GitRepository.createClient().

  2. Configure the client

    Some git client commands may (or may not) require additional setup of the client to successfully finish their work. One quite usual use case is setting an instance of GitClientCallback to the client so commands like push, fetch or pull may connect to and access a remote repository. To set an instance of GitClientCallback use setCallback(org.netbeans.libs.git.GitClientCallback) method.

  3. Attaching listeners

    Certain git commands may take a long time to finish and they are capable of notifying the world about the progress in their work.
    If you want to be notified about such changes while the command is in process, attach a listener to the client via addNotificationListener(org.netbeans.libs.git.progress.NotificationListener).
    An example can be the log command. Digging through the history may take a lot of time so if you do not want to wait for the complete result only and want to present the commit information incrementally as it is accepted one by one into the result, you can do so by adding an instance of RevisionInfoListener to the client.

  4. Running git commands

    When you have the client correctly set up, you may call any git command we support. The commands are mapped to appropriate methods in GitClient.
    Every method representing a git command accepts as a parameter an instance of ProgressMonitor. With that class you may affect the flow of commands - it has the ability to cancel running git commands - and listen for error or information messages the commands produce.


  5. Nested Class Summary
    static class GitClient.DiffMode
              Used as a parameter in commands comparing two trees in the repository.
    static class GitClient.ResetType
              Used as a parameter of reset(java.lang.String, org.netbeans.libs.git.GitClient.ResetType, org.netbeans.libs.git.progress.ProgressMonitor) to set the behavior of the command.
     
    Method Summary
     void add(File[] roots, ProgressMonitor monitor)
              Adds all files under the given roots to the index
     void addNotificationListener(NotificationListener listener)
              Adds a listener of any kind to the client.
     GitBlameResult blame(File file, String revision, ProgressMonitor monitor)
              Annotates lines of a given file in a given revision and returns the result with annotate information.
     boolean catFile(File file, String revision, OutputStream out, ProgressMonitor monitor)
              Prints file's content in the given revision to output stream
     boolean catIndexEntry(File file, int stage, OutputStream out, ProgressMonitor monitor)
              Prints content of an index entry accordant to the given file to the given output stream
     void checkout(File[] roots, String revision, boolean recursively, ProgressMonitor monitor)
              Checks out the index into the working copy root.
     void checkoutRevision(String revision, boolean failOnConflict, ProgressMonitor monitor)
              Checks out a given revision, modifies the Index as well as the Working tree.
     void clean(File[] roots, ProgressMonitor monitor)
              Cleans the working tree by recursively removing files that are not under version control starting from the given roots.
     GitRevisionInfo commit(File[] roots, String commitMessage, GitUser author, GitUser commiter, ProgressMonitor monitor)
              Commits all changes made in the index to all files under the given roots
     void copyAfter(File source, File target, ProgressMonitor monitor)
              The index entries representing files under the source are copied and the newly created entries represent the corresponding files under the target.
     GitBranch createBranch(String branchName, String revision, ProgressMonitor monitor)
              Creates a new branch with a given name, starting at the given revision
     GitTag createTag(String tagName, String taggedObject, String message, boolean signed, boolean forceUpdate, ProgressMonitor monitor)
              Creates a tag for any object represented by a given taggedObjectId.
     void deleteBranch(String branchName, boolean forceDeleteUnmerged, ProgressMonitor monitor)
              Deletes a given branch from the repository
     void deleteTag(String tagName, ProgressMonitor monitor)
              Deletes a given tag from the repository
     void exportCommit(String commit, OutputStream out, ProgressMonitor monitor)
              Exports a given commit in the format accepted by git am
     void exportDiff(File[] roots, GitClient.DiffMode mode, OutputStream out, ProgressMonitor monitor)
              Exports uncommitted changes in files under given roots to the given output stream
     Map<String,GitTransportUpdate> fetch(String remote, List<String> fetchRefSpecifications, ProgressMonitor monitor)
              Fetches remote changes from a remote repository for given reference specifications.
     Map<String,GitTransportUpdate> fetch(String remote, ProgressMonitor monitor)
              Fetches remote changes for references specified in the config file under a given remote.
     Map<String,GitBranch> getBranches(boolean all, ProgressMonitor monitor)
              Returns all known branches from the repository
     GitRevisionInfo getCommonAncestor(String[] revisions, ProgressMonitor monitor)
              Returns a common ancestor for given revisions or null if none found.
     Map<File,GitStatus> getConflicts(File[] roots, ProgressMonitor monitor)
              Similar to getStatus(java.io.File[], org.netbeans.libs.git.progress.ProgressMonitor), but returns only conflicts.
     GitRevisionInfo getPreviousRevision(File file, String revision, ProgressMonitor monitor)
              Returns an ancestor revision that affected a given file
     GitRemoteConfig getRemote(String remoteName, ProgressMonitor monitor)
              Returns remote configuration set up for this repository identified by a given remoteName
     Map<String,GitRemoteConfig> getRemotes(ProgressMonitor monitor)
              Returns all remote configurations set up for this repository
     GitRepositoryState getRepositoryState(ProgressMonitor monitor)
              Returns the current state of the repository this client is associated with.
     Map<File,GitStatus> getStatus(File[] roots, ProgressMonitor monitor)
              Returns an array of statuses for files under given roots
     Map<String,GitTag> getTags(ProgressMonitor monitor, boolean allTags)
              Returns all tags in the repository
     GitUser getUser()
              Returns the user from this clients repository
     File[] ignore(File[] files, ProgressMonitor monitor)
              Ignores given files and add their path into gitignore file.
     void init(ProgressMonitor monitor)
              Initializes an empty git repository in a folder specified in the constructor.
     File[] listModifiedIndexEntries(File[] roots, ProgressMonitor monitor)
              Returns files that are marked as modified between the HEAD and Index.
     Map<String,GitBranch> listRemoteBranches(String remoteRepositoryUrl, ProgressMonitor monitor)
              Returns available branches in a given remote repository
     Map<String,String> listRemoteTags(String remoteRepositoryUrl, ProgressMonitor monitor)
              Returns pairs tag name/id from a given remote repository
     GitRevisionInfo[] log(SearchCriteria searchCriteria, ProgressMonitor monitor)
              Digs through the repository's history and returns revisions according to the given search criteria.
     GitRevisionInfo log(String revision, ProgressMonitor monitor)
              Digs through the repository's history and returns the revision information belonging to the given revision string.
     GitMergeResult merge(String revision, ProgressMonitor monitor)
              Merges a given revision with the current head
     GitPullResult pull(String remote, List<String> fetchRefSpecifications, String branchToMerge, ProgressMonitor monitor)
              Pulls changes from a remote repository and merges a given remote branch to an active one.
     GitPushResult push(String remote, List<String> pushRefSpecifications, List<String> fetchRefSpecifications, ProgressMonitor monitor)
              Pushes changes to a remote repository specified by remote for given reference specifications.
     void remove(File[] roots, boolean cached, ProgressMonitor monitor)
              Removes given files/folders from the index and/or from the working tree
     void removeNotificationListener(NotificationListener listener)
              Removes an already added notification listener.
     void removeRemote(String remote, ProgressMonitor monitor)
              Removes remote configuration from the repository's config file
     void rename(File source, File target, boolean after, ProgressMonitor monitor)
              Renames source file or folder to target
     void reset(File[] roots, String revision, boolean recursively, ProgressMonitor monitor)
              Updates entries for given files in the index with those from the given revision
     void reset(String revision, GitClient.ResetType resetType, ProgressMonitor monitor)
              Sets HEAD to the given revision and updates index and working copy accordingly to the given reset type
     GitRevertResult revert(String revision, String commitMessage, boolean commit, ProgressMonitor monitor)
              Reverts already committed changes and creates an inverse commit.
     void setCallback(GitClientCallback callback)
              Sets credentials callback for this client.
     void setRemote(GitRemoteConfig remoteConfig, ProgressMonitor monitor)
              Sets the remote configuration in the configuration file.
     File[] unignore(File[] files, ProgressMonitor monitor)
              Unignores given files
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Method Detail

    add

    public void add(File[] roots,
                    ProgressMonitor monitor)
             throws GitException
    Adds all files under the given roots to the index

    Parameters:
    roots - files or folders to add recursively to the index
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    addNotificationListener

    public void addNotificationListener(NotificationListener listener)
    Adds a listener of any kind to the client. Git commands that support a listener will notify the appropriate ones while working.

    Parameters:
    listener - a listener to add

    blame

    public GitBlameResult blame(File file,
                                String revision,
                                ProgressMonitor monitor)
                         throws GitException.MissingObjectException,
                                GitException
    Annotates lines of a given file in a given revision and returns the result with annotate information.

    Parameters:
    file - file to be annotated
    revision - a revision the file should be annotated in or null for blaming a checked-out file against HEAD
    monitor - progress monitor
    Returns:
    annotation information
    Throws:
    GitException.MissingObjectException - when the revision revision cannot be resolved.
    GitException - an unexpected error occurs

    catFile

    public boolean catFile(File file,
                           String revision,
                           OutputStream out,
                           ProgressMonitor monitor)
                    throws GitException.MissingObjectException,
                           GitException
    Prints file's content in the given revision to output stream

    Parameters:
    file - file to cat
    revision - git revision, never null
    out - output stream to print the content to.
    Returns:
    true if the file was found in the specified revision and printed to out, otherwise false
    Throws:
    GitException.MissingObjectException - if the given revision does not exist
    GitException - an unexpected error occurs

    catIndexEntry

    public boolean catIndexEntry(File file,
                                 int stage,
                                 OutputStream out,
                                 ProgressMonitor monitor)
                          throws GitException
    Prints content of an index entry accordant to the given file to the given output stream

    Parameters:
    file - file whose relevant index entry to cat
    stage - version of the file in the index. In case of a merge conflict there are usually more versions of the file. 0 for normal non-conflict version, 1 for the base version, 2 for the first merged version ("ours") and 3 for the second merged version ("theirs").
    out - output stream
    Returns:
    true if the file was found in the index and printed to out, otherwise false
    Throws:
    GitException - an unexpected error occurs

    checkout

    public void checkout(File[] roots,
                         String revision,
                         boolean recursively,
                         ProgressMonitor monitor)
                  throws GitException.MissingObjectException,
                         GitException
    Checks out the index into the working copy root. Does not move current HEAD.

    Parameters:
    revision - if not null, index is updated with the revision content before checking out to WC
    roots - files/folders to checkout
    recursively - if set to true, all files under given roots will be checked out, otherwise only roots and direct file children will be affected.
    Throws:
    GitException - an unexpected error occurs
    GitException.MissingObjectException

    checkoutRevision

    public void checkoutRevision(String revision,
                                 boolean failOnConflict,
                                 ProgressMonitor monitor)
                          throws GitException.MissingObjectException,
                                 GitException
    Checks out a given revision, modifies the Index as well as the Working tree.

    Parameters:
    revision - cannot be null. If the value equals to anything other than an existing branch name, the revision will be checked out and the working tree will be in the detached HEAD state.
    failOnConflict - if set to false, the command tries to merge local changes into the new branch
    Throws:
    GitException - an unexpected error occurs
    GitException.MissingObjectException

    clean

    public void clean(File[] roots,
                      ProgressMonitor monitor)
               throws GitException
    Cleans the working tree by recursively removing files that are not under version control starting from the given roots.

    Parameters:
    roots - files or folders to recursively remove from disk, versioned files under these files will not be deleted.
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    commit

    public GitRevisionInfo commit(File[] roots,
                                  String commitMessage,
                                  GitUser author,
                                  GitUser commiter,
                                  ProgressMonitor monitor)
                           throws GitException
    Commits all changes made in the index to all files under the given roots

    Parameters:
    roots - files or folders to recursively commit.
    commitMessage - commit message
    author - person who is the author of the changes to be committed
    commiter - person who is committing the changes, may not be the same person as author.
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    copyAfter

    public void copyAfter(File source,
                          File target,
                          ProgressMonitor monitor)
                   throws GitException
    The index entries representing files under the source are copied and the newly created entries represent the corresponding files under the target. Modifies only the index.

    Parameters:
    source - source tree to copy
    target - target file or folder the source should be copied onto.
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    createBranch

    public GitBranch createBranch(String branchName,
                                  String revision,
                                  ProgressMonitor monitor)
                           throws GitException
    Creates a new branch with a given name, starting at the given revision

    Parameters:
    branchName - name that should be assigned to the new branch
    revision - revision that should be referenced by the new branch
    monitor - progress monitor
    Returns:
    created branch
    Throws:
    GitException - an unexpected error occurs

    createTag

    public GitTag createTag(String tagName,
                            String taggedObject,
                            String message,
                            boolean signed,
                            boolean forceUpdate,
                            ProgressMonitor monitor)
                     throws GitException
    Creates a tag for any object represented by a given taggedObjectId. If message is set to null or an empty value and signed set to false than this method creates a lightweight tag.

    Parameters:
    tagName - name of the new tag
    taggedObject - object to tag
    message - tag message
    signed - if the tag should be signed. Currently unsupported.
    forceUpdate - if a tag with the same name already exists, the method fails and throws an exception unless this is set to true. In that case the old tag is replaced with the new one.
    monitor - progress monitor
    Returns:
    the created tag
    Throws:
    GitException - an unexpected error occurs

    deleteBranch

    public void deleteBranch(String branchName,
                             boolean forceDeleteUnmerged,
                             ProgressMonitor monitor)
                      throws GitException.NotMergedException,
                             GitException
    Deletes a given branch from the repository

    Parameters:
    branchName - name of a branch to delete.
    forceDeleteUnmerged - if set to true then trying to delete an unmerged branch will not fail but will forcibly delete the branch
    monitor - progress monitor
    Throws:
    GitException.NotMergedException - branch has not been fully merged yet and forceDeleteUnmerged is set to false
    GitException - an unexpected error occurs

    deleteTag

    public void deleteTag(String tagName,
                          ProgressMonitor monitor)
                   throws GitException
    Deletes a given tag from the repository

    Parameters:
    tagName - name of a tag to delete
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    exportCommit

    public void exportCommit(String commit,
                             OutputStream out,
                             ProgressMonitor monitor)
                      throws GitException
    Exports a given commit in the format accepted by git am

    Parameters:
    commit - id of a commit whose diff to export
    out - output stream the diff will be printed to
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    exportDiff

    public void exportDiff(File[] roots,
                           GitClient.DiffMode mode,
                           OutputStream out,
                           ProgressMonitor monitor)
                    throws GitException
    Exports uncommitted changes in files under given roots to the given output stream

    Parameters:
    roots - the diff will be exported only for modified files under these roots, can be empty to export all modifications in the whole working tree
    mode - defines the compared trees
    out - output stream the diff will be printed to
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    fetch

    public Map<String,GitTransportUpdate> fetch(String remote,
                                                ProgressMonitor monitor)
                                         throws GitException.AuthorizationException,
                                                GitException
    Fetches remote changes for references specified in the config file under a given remote.

    Parameters:
    remote - should be a name of a remote set up in the repository config file
    monitor - progress monitor
    Returns:
    result of the command with listed local reference updates
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException - an unexpected error occurs

    fetch

    public Map<String,GitTransportUpdate> fetch(String remote,
                                                List<String> fetchRefSpecifications,
                                                ProgressMonitor monitor)
                                         throws GitException.AuthorizationException,
                                                GitException
    Fetches remote changes from a remote repository for given reference specifications.

    Parameters:
    remote - preferably a name of a remote, but can also be directly a URL of a remote repository
    fetchRefSpecifications - list of reference specifications describing the objects to fetch from the remote repository
    monitor - progress monitor
    Returns:
    result of the command with listed local reference updates
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException - an unexpected error occurs

    getBranches

    public Map<String,GitBranch> getBranches(boolean all,
                                             ProgressMonitor monitor)
                                      throws GitException
    Returns all known branches from the repository

    Parameters:
    all - if false then only local (and no remote) branches will be returned
    Returns:
    all known branches in the repository
    Throws:
    GitException - an unexpected error occurs

    getTags

    public Map<String,GitTag> getTags(ProgressMonitor monitor,
                                      boolean allTags)
                               throws GitException
    Returns all tags in the repository

    Parameters:
    monitor - progress monitor
    allTags - if set to false, only commit tags, otherwise tags for all objects are returned
    Returns:
    all known tags from the repository
    Throws:
    GitException - an unexpected error occurs

    getCommonAncestor

    public GitRevisionInfo getCommonAncestor(String[] revisions,
                                             ProgressMonitor monitor)
                                      throws GitException
    Returns a common ancestor for given revisions or null if none found.

    Parameters:
    revisions - revisions whose common ancestor to search
    monitor - progress monitor
    Returns:
    common ancestor for given revisions or null if none found.
    Throws:
    GitException - an unexpected error occurs

    getPreviousRevision

    public GitRevisionInfo getPreviousRevision(File file,
                                               String revision,
                                               ProgressMonitor monitor)
                                        throws GitException
    Returns an ancestor revision that affected a given file

    Parameters:
    file - limit the result only on revision that actually modified somehow the file
    revision - revision to start search from, only its ancestors will be investigated
    monitor - progress monitor
    Returns:
    an ancestor of a given revision that affected the given file or null if none found.
    Throws:
    GitException - an unexpected error occurs

    getConflicts

    public Map<File,GitStatus> getConflicts(File[] roots,
                                            ProgressMonitor monitor)
                                     throws GitException
    Similar to getStatus(java.io.File[], org.netbeans.libs.git.progress.ProgressMonitor), but returns only conflicts.

    Parameters:
    roots - files to search the conflicts under
    monitor - progress monitor
    Returns:
    conflicted files and their accordant statuses
    Throws:
    GitException - an unexpected error occurs

    getStatus

    public Map<File,GitStatus> getStatus(File[] roots,
                                         ProgressMonitor monitor)
                                  throws GitException
    Returns an array of statuses for files under given roots

    Parameters:
    roots - root folders or files to search under
    Returns:
    status array
    Throws:
    GitException - an unexpected error occurs

    getRemote

    public GitRemoteConfig getRemote(String remoteName,
                                     ProgressMonitor monitor)
                              throws GitException
    Returns remote configuration set up for this repository identified by a given remoteName

    Parameters:
    remoteName - name under which the remote is stored in repository's config file
    monitor - progress monitor
    Returns:
    remote config or null if no remote with such name was found
    Throws:
    GitException - an unexpected error occurs

    getRemotes

    public Map<String,GitRemoteConfig> getRemotes(ProgressMonitor monitor)
                                           throws GitException
    Returns all remote configurations set up for this repository

    Parameters:
    monitor - progress monitor
    Returns:
    all known remote configurations
    Throws:
    GitException - an unexpected error occurs

    getRepositoryState

    public GitRepositoryState getRepositoryState(ProgressMonitor monitor)
                                          throws GitException
    Returns the current state of the repository this client is associated with. The state indicates what commands may be run on the repository and if the repository requires any additional commands to get into the normal state.

    Parameters:
    monitor - progress monitor
    Returns:
    current repository state
    Throws:
    GitException - an unexpected error occurs

    getUser

    public GitUser getUser()
                    throws GitException
    Returns the user from this clients repository

    Throws:
    GitException - an unexpected error occurs

    ignore

    public File[] ignore(File[] files,
                         ProgressMonitor monitor)
                  throws GitException
    Ignores given files and add their path into gitignore file.

    Parameters:
    files - files to ignore
    monitor - progress monitor
    Returns:
    array of .gitignore modified during the ignore process
    Throws:
    GitException - an unexpected error occurs

    init

    public void init(ProgressMonitor monitor)
              throws GitException
    Initializes an empty git repository in a folder specified in the constructor. The repository must not yet exist - meaning there cannot not be a .git folder in the given folder - however the folder itself may exist and contain any other source files (except for git repository metadata).

    Parameters:
    monitor - progress monitor
    Throws:
    GitException - if the repository could not be created either because it already exists inside workDir or cannot be created for other reasons.

    listModifiedIndexEntries

    public File[] listModifiedIndexEntries(File[] roots,
                                           ProgressMonitor monitor)
                                    throws GitException
    Returns files that are marked as modified between the HEAD and Index.

    Parameters:
    roots - files or folders to search for modified files.
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    listRemoteBranches

    public Map<String,GitBranch> listRemoteBranches(String remoteRepositoryUrl,
                                                    ProgressMonitor monitor)
                                             throws GitException.AuthorizationException,
                                                    GitException
    Returns available branches in a given remote repository

    Parameters:
    remoteRepositoryUrl - url of the remote repository
    monitor - progress monitor
    Returns:
    collection of available branches in the remote repository
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException - an unexpected error occurs

    listRemoteTags

    public Map<String,String> listRemoteTags(String remoteRepositoryUrl,
                                             ProgressMonitor monitor)
                                      throws GitException.AuthorizationException,
                                             GitException
    Returns pairs tag name/id from a given remote repository

    Parameters:
    remoteRepositoryUrl - url of the remote repository
    monitor - progress monitor
    Returns:
    remote repository tags
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException - an unexpected error occurs

    log

    public GitRevisionInfo log(String revision,
                               ProgressMonitor monitor)
                        throws GitException.MissingObjectException,
                               GitException
    Digs through the repository's history and returns the revision information belonging to the given revision string.

    Parameters:
    revision - revision to search in the history
    monitor - progress monitor
    Returns:
    revision information
    Throws:
    GitException.MissingObjectException - no such revision exists
    GitException - an unexpected error occurs

    log

    public GitRevisionInfo[] log(SearchCriteria searchCriteria,
                                 ProgressMonitor monitor)
                          throws GitException.MissingObjectException,
                                 GitException
    Digs through the repository's history and returns revisions according to the given search criteria.

    Parameters:
    searchCriteria - criteria filtering the returned revisions
    monitor - progress monitor
    Returns:
    revisions that follow the given search criteria
    Throws:
    GitException.MissingObjectException - revision specified in search criteria (or head if no such revision is specified) does not exist
    GitException - an unexpected error occurs

    merge

    public GitMergeResult merge(String revision,
                                ProgressMonitor monitor)
                         throws GitException.CheckoutConflictException,
                                GitException
    Merges a given revision with the current head

    Parameters:
    revision - id of a revision to merge.
    monitor - progress monitor
    Returns:
    result of the merge
    Throws:
    GitException.CheckoutConflictException - there are local modifications in Working Tree, merge fails in such a case
    GitException - an unexpected error occurs

    pull

    public GitPullResult pull(String remote,
                              List<String> fetchRefSpecifications,
                              String branchToMerge,
                              ProgressMonitor monitor)
                       throws GitException.AuthorizationException,
                              GitException.CheckoutConflictException,
                              GitException.MissingObjectException,
                              GitException
    Pulls changes from a remote repository and merges a given remote branch to an active one.

    Parameters:
    remote - preferably a name of a remote, but can also be directly a URL of a remote repository
    fetchRefSpecifications - list of reference specifications describing what objects to fetch from the remote repository
    branchToMerge - a remote branch that will be merged into an active branch
    monitor - progress monitor
    Returns:
    result of the command containing the list of updated local references
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException.CheckoutConflictException - there are local changes in the working tree that would result in a merge conflict
    GitException.MissingObjectException - given branch to merge does not exist
    GitException - an unexpected error occurs

    push

    public GitPushResult push(String remote,
                              List<String> pushRefSpecifications,
                              List<String> fetchRefSpecifications,
                              ProgressMonitor monitor)
                       throws GitException.AuthorizationException,
                              GitException
    Pushes changes to a remote repository specified by remote for given reference specifications.

    Parameters:
    remote - preferably a name of a remote defined in the repository's config, but can also be directly a URL of a remote repository
    pushRefSpecifications - list of reference specifications describing the list of references to push
    fetchRefSpecifications - list of fetch reference specifications describing the list of local references to update to correctly track remote repository branches.
    monitor - progress monitor
    Returns:
    result of the push process with information about updated local and remote references
    Throws:
    GitException.AuthorizationException - when the authentication or authorization fails
    GitException - an unexpected error occurs

    remove

    public void remove(File[] roots,
                       boolean cached,
                       ProgressMonitor monitor)
                throws GitException
    Removes given files/folders from the index and/or from the working tree

    Parameters:
    roots - files/folders to remove, can not be empty
    cached - if true the working tree will not be affected
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    removeNotificationListener

    public void removeNotificationListener(NotificationListener listener)
    Removes an already added notification listener. Such a listener will not get notifications from the git subsystem.

    Parameters:
    listener - listener to remove.

    removeRemote

    public void removeRemote(String remote,
                             ProgressMonitor monitor)
                      throws GitException
    Removes remote configuration from the repository's config file

    Parameters:
    remote - name of the remote
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    rename

    public void rename(File source,
                       File target,
                       boolean after,
                       ProgressMonitor monitor)
                throws GitException
    Renames source file or folder to target

    Parameters:
    source - file or folder to be renamed
    target - target file or folder. Must not yet exist.
    after - set to true if you don't only want to correct the index
    monitor - progress monitor
    Throws:
    GitException - an unexpected error occurs

    reset

    public void reset(File[] roots,
                      String revision,
                      boolean recursively,
                      ProgressMonitor monitor)
               throws GitException.MissingObjectException,
                      GitException
    Updates entries for given files in the index with those from the given revision

    Parameters:
    revision - revision to go back to
    roots - files or folders to update in the index
    recursively - if set to true, all files under given roots will be affected, otherwise only roots and direct file children will be modified in the index.
    monitor - progress monitor
    Throws:
    GitException.MissingObjectException - if the given revision does not exist
    GitException - an unexpected error occurs

    reset

    public void reset(String revision,
                      GitClient.ResetType resetType,
                      ProgressMonitor monitor)
               throws GitException.MissingObjectException,
                      GitException
    Sets HEAD to the given revision and updates index and working copy accordingly to the given reset type

    Parameters:
    revision - revision HEAD will reference to
    resetType - type of reset, see git help reset
    monitor - progress monitor
    Throws:
    GitException.MissingObjectException - if the given revision does not exist
    GitException - an unexpected error occurs

    revert

    public GitRevertResult revert(String revision,
                                  String commitMessage,
                                  boolean commit,
                                  ProgressMonitor monitor)
                           throws GitException.MissingObjectException,
                                  GitException.CheckoutConflictException,
                                  GitException
    Reverts already committed changes and creates an inverse commit.

    Parameters:
    revision - the id of a commit to revert
    commitMessage - used as the commit message for the revert commit. If set to null or an empty value, a default value will be used for the commit message
    commit - if set to false, the revert modifications will not be committed but will stay in index
    monitor - progress monitor
    Returns:
    result of the revert command
    Throws:
    GitException.MissingObjectException - if the given revision does not exist
    GitException.CheckoutConflictException - there are local modifications in Working Tree, merge fails in such a case
    GitException - an unexpected error occurs

    setCallback

    public void setCallback(GitClientCallback callback)
    Sets credentials callback for this client. Some actions (like inter-repository commands) may need it for its work to communicate with an external repository.

    Parameters:
    callback - callback implementation providing credentials for an authentication process.

    setRemote

    public void setRemote(GitRemoteConfig remoteConfig,
                          ProgressMonitor monitor)
                   throws GitException
    Sets the remote configuration in the configuration file.

    Parameters:
    remoteConfig - new remote config to store as a remote section in the repository's config file.
    monitor - progress monitor
    Throws:
    GitException

    unignore

    public File[] unignore(File[] files,
                           ProgressMonitor monitor)
                    throws GitException
    Unignores given files

    Parameters:
    files - files to mark unignored again and remove their respective record from gitignore files.
    monitor - progress monitor
    Returns:
    array of .gitignore files modified during the unignore process
    Throws:
    GitException - an unexpected error occurs

    org.netbeans.libs.git/1 1.1

    Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.