Class CLIGitCommand


  • public class CLIGitCommand
    extends Main
    • Constructor Detail

      • CLIGitCommand

        public CLIGitCommand​(Repository db)
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Executes git commands (with arguments) specified on the command line. The git repository (same for all commands) can be specified via system property "-Dgit_work_tree=path_to_work_tree". If the property is not set, current directory is used.
        Parameters:
        args - each element in the array must be a valid git command line, e.g. "git branch -h"
        Throws:
        java.lang.Exception
      • execute

        public static java.util.List<java.lang.String> execute​(java.lang.String str,
                                                               Repository db)
                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeRaw

        public static CLIGitCommand.Result executeRaw​(java.lang.String str,
                                                      Repository db)
                                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeUnchecked

        public static java.util.List<java.lang.String> executeUnchecked​(java.lang.String str,
                                                                        Repository db)
                                                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getOutput

        private static java.util.List<java.lang.String> getOutput​(CLIGitCommand.Result result)
      • run

        private void run​(java.lang.String commandLine)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • convertToMainArgs

        private static java.lang.String[] convertToMainArgs​(java.lang.String str)
                                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createErrorWriter

        java.io.PrintWriter createErrorWriter()
        Overrides:
        createErrorWriter in class Main
      • init

        void init​(TextBuiltin cmd)
           throws java.io.IOException
        Overrides:
        init in class Main
        Throws:
        java.io.IOException
      • openGitDir

        protected Repository openGitDir​(java.lang.String aGitdir)
                                 throws java.io.IOException
        Description copied from class: Main
        Evaluate the --git-dir option and open the repository.
        Overrides:
        openGitDir in class Main
        Parameters:
        aGitdir - the --git-dir option given on the command line. May be null if it was not supplied.
        Returns:
        the repository to operate on.
        Throws:
        java.io.IOException - the repository cannot be opened.
      • exit

        void exit​(int status,
                  java.lang.Exception t)
           throws java.lang.Exception
        Overrides:
        exit in class Main
        t - can be null
        Throws:
        java.lang.Exception
      • split

        static java.lang.String[] split​(java.lang.String commandLine)
        Split a command line into a string array. A copy of Gerrit's com.google.gerrit.sshd.CommandFactoryProvider#split(String)
        Parameters:
        commandLine - a command line
        Returns:
        the array