/// <summary> /// * Updates local branch (N/A for checkout to detached HEAD) /// * Updates HEAD /// * Calls base to update shallow file and remote branch. /// </summary> protected override void UpdateRefs(string branchOrCommit, bool isBranch, GitRefs refs) { UpdateRefsHelper refHelper = new UpdateRefsHelper(this.Enlistment); if (isBranch) { KeyValuePair <string, string> remoteRef = refs.GetBranchRefPairs().Single(); string remoteBranch = remoteRef.Key; string fullLocalBranchName = branchOrCommit.StartsWith("refs/heads/") ? branchOrCommit : ("refs/heads/" + branchOrCommit); this.HasFailures |= !refHelper.UpdateRef(this.Tracer, fullLocalBranchName, remoteRef.Value); this.HasFailures |= !refHelper.UpdateRef(this.Tracer, "HEAD", fullLocalBranchName); } else { this.HasFailures |= !refHelper.UpdateRef(this.Tracer, "HEAD", branchOrCommit); } base.UpdateRefs(branchOrCommit, isBranch, refs); }
/// <summary> /// * Updates any remote branch (N/A for fetch of detached commit) /// * Updates shallow file /// </summary> protected virtual void UpdateRefs(string branchOrCommit, bool isBranch, GitRefs refs) { UpdateRefsHelper refHelper = new UpdateRefsHelper(this.Enlistment); string commitSha = null; if (isBranch) { KeyValuePair <string, string> remoteRef = refs.GetBranchRefPairs().Single(); string remoteBranch = remoteRef.Key; commitSha = remoteRef.Value; this.HasFailures |= !refHelper.UpdateRef(this.Tracer, remoteBranch, commitSha); } else { commitSha = branchOrCommit; } // Update shallow file to ensure this is a valid shallow repo File.AppendAllText(Path.Combine(this.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Shallow), commitSha + "\n"); }