示例#1
0
        public GitCatFileProcess(ITracer tracer, Enlistment enlistment, string catFileArgs)
        {
            // This git.exe should not need/use the working directory of the repo.
            // Run git.exe in Environment.SystemDirectory to ensure the git.exe process does not touch the working directory
            this.catFileProcess = new GitProcess(enlistment).GetGitProcess(
                "cat-file " + catFileArgs,
                workingDirectory: Environment.SystemDirectory,
                dotGitDirectory: enlistment.DotGitRoot,
                useReadObjectHook: false,
                redirectStandardError: true);

            this.catFileProcess.ErrorDataReceived += (sender, args) =>
            {
                if (args.Data != null)
                {
                    EventMetadata metadata = new EventMetadata();
                    metadata["Area"]  = "GitCatFileProcess";
                    metadata["Args"]  = catFileArgs;
                    metadata["Error"] = args.Data;
                    tracer.RelatedError(metadata);
                }
            };

            this.catFileProcess.Start();

            // We have to use a job to ensure that we can kill the process correctly.  The git.exe process that we launch
            // immediately creates a child git.exe process, and if we just kill the process we created, the other one gets orphaned.
            // By adding our process to a job and closing the job, we guarantee that both processes will exit.
            this.job = new WindowsProcessJob(this.catFileProcess);

            this.StdIn            = this.catFileProcess.StandardInput;
            this.StdOutCanTimeout = this.catFileProcess.StandardOutput;
        }
示例#2
0
        public void Kill()
        {
            if (this.job != null)
            {
                this.job.Dispose();
                this.job = null;
            }

            if (this.catFileProcess != null)
            {
                this.catFileProcess.Dispose();
                this.catFileProcess = null;
            }
        }
示例#3
0
        public GitCatFileProcess(Enlistment enlistment, string catFileArgs)
        {
            // Errors only happen if we use incorrect 'cat-file --batch' parameters. Functional tests will catch these cases.

            // This git.exe should not need/use the working directory of the repo.
            // Run git.exe in Environment.SystemDirectory to ensure the git.exe process
            // does not touch the working directory
            // TODO: 851558 Capture and log standard error output
            this.catFileProcess = new GitProcess(enlistment).GetGitProcess(
                "cat-file " + catFileArgs,
                workingDirectory: Environment.SystemDirectory,
                dotGitDirectory: enlistment.DotGitRoot,
                useReadObjectHook: false,
                redirectStandardError: false);
            this.catFileProcess.Start();

            // We have to use a job to ensure that we can kill the process correctly.  The git.exe process that we launch
            // immediately creates a child git.exe process, and if we just kill the process we created, the other one gets orphaned.
            // By adding our process to a job and closing the job, we guarantee that both processes will exit.
            this.job = new WindowsProcessJob(this.catFileProcess);

            this.StdIn  = this.catFileProcess.StandardInput;
            this.StdOut = this.catFileProcess.StandardOutput;
        }