Example #1
0
        public void PerformDiff(string targetCommitSha)
        {
            string targetTreeSha;
            string headTreeSha;

            using (GitCatFileBatchProcess catFile = new GitCatFileBatchProcess(this.tracer, this.enlistment))
            {
                targetTreeSha = catFile.GetTreeSha_CanTimeout(targetCommitSha);
                headTreeSha   = catFile.GetTreeSha_CanTimeout("HEAD");
            }

            this.PerformDiff(headTreeSha, targetTreeSha);
        }
Example #2
0
        public void PerformDiff()
        {
            using (GitCatFileBatchProcess catFile = new GitCatFileBatchProcess(this.enlistment))
            {
                GitProcess git      = new GitProcess(this.enlistment);
                string     repoRoot = git.GetRepoRoot();

                string targetTreeSha = catFile.GetTreeSha(this.targetCommitSha);
                string headTreeSha   = catFile.GetTreeSha("HEAD");

                EventMetadata metadata = new EventMetadata();
                metadata.Add("TargetTreeSha", targetTreeSha);
                metadata.Add("HeadTreeSha", headTreeSha);
                using (ITracer activity = this.tracer.StartActivity("PerformDiff", EventLevel.Informational, metadata))
                {
                    metadata = new EventMetadata();
                    if (headTreeSha == null)
                    {
                        // Nothing is checked out (fresh git init), so we must search the entire tree.
                        git.LsTree(targetTreeSha, this.EnqueueOperationsFromLsTreeLine, recursive: true, showAllTrees: true);
                        metadata.Add("Operation", "LsTree");
                    }
                    else
                    {
                        // Diff head and target, determine what needs to be done.
                        git.DiffTree(headTreeSha, targetTreeSha, line => this.EnqueueOperationsFromDiffTreeLine(this.tracer, repoRoot, line));
                        metadata.Add("Operation", "DiffTree");
                    }

                    this.RequiredBlobs.CompleteAdding();

                    metadata.Add("Success", !this.HasFailures);
                    metadata.Add("DirectoryOperationsCount", this.TotalDirectoryOperations);
                    metadata.Add("FileDeleteOperationsCount", this.TotalFileDeletes);
                    metadata.Add("RequiredBlobsCount", this.RequiredBlobs.Count);
                    activity.Stop(metadata);
                }
            }
        }