Class CherryPickCommand

  • All Implemented Interfaces:
    java.util.concurrent.Callable<CherryPickResult>

    public class CherryPickCommand
    extends GitCommand<CherryPickResult>
    A class used to execute a cherry-pick 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())
    See Also:
    Git documentation about cherry-pick
    • Constructor Detail

      • CherryPickCommand

        protected CherryPickCommand​(Repository repo)
        Parameters:
        repo -
    • Method Detail

      • include

        public CherryPickCommand include​(Ref commit)
        Parameters:
        commit - a reference to a commit which is cherry-picked to the current head
        Returns:
        this
      • include

        public CherryPickCommand include​(AnyObjectId commit)
        Parameters:
        commit - the Id of a commit which is cherry-picked to the current head
        Returns:
        this
      • include

        public CherryPickCommand include​(java.lang.String name,
                                         AnyObjectId commit)
        Parameters:
        name - a name given to the commit
        commit - the Id of a commit which is cherry-picked to the current head
        Returns:
        this
      • setOurCommitName

        public CherryPickCommand setOurCommitName​(java.lang.String ourCommitName)
        Parameters:
        ourCommitName - the name that should be used in the "OURS" place for conflict markers
        Returns:
        this
      • setReflogPrefix

        public CherryPickCommand setReflogPrefix​(java.lang.String prefix)
        Set the prefix to use in the reflog.

        This is primarily needed for implementing rebase in terms of cherry-picking

        Parameters:
        prefix - including ":"
        Returns:
        this
        Since:
        3.1
      • setStrategy

        public CherryPickCommand setStrategy​(MergeStrategy strategy)
        Parameters:
        strategy - The merge strategy to use during this Cherry-pick.
        Returns:
        this
        Since:
        3.4
      • setMainlineParentNumber

        public CherryPickCommand setMainlineParentNumber​(int mainlineParentNumber)
        Parameters:
        mainlineParentNumber - the (1-based) parent number to diff against. This allows cherry-picking of merges.
        Returns:
        this
        Since:
        3.4
      • setNoCommit

        public CherryPickCommand setNoCommit​(boolean noCommit)
        Allows cherry-picking changes without committing them.

        NOTE: The behavior of cherry-pick is undefined if you pick multiple commits or if HEAD does not match the index state before cherry-picking.

        Parameters:
        noCommit - true to cherry-pick without committing, false to commit after each pick (default)
        Returns:
        this
        Since:
        3.5