private void LogCommit(Commit commit, bool amendPreviousCommit, bool isHeadOrphaned, bool isMergeCommit) { // Compute reflog message string reflogMessage = "commit"; if (isHeadOrphaned) { reflogMessage += " (initial)"; } else if (amendPreviousCommit) { reflogMessage += " (amend)"; } else if (isMergeCommit) { reflogMessage += " (merge)"; } reflogMessage = string.Format("{0}: {1}", reflogMessage, commit.MessageShort); var headRef = Refs.Head; // in case HEAD targets a symbolic reference, log commit on the targeted direct reference if (headRef is SymbolicReference) { Refs.Log(headRef.ResolveToDirectReference()).Append(commit.Id, reflogMessage, commit.Committer); } // Log commit on HEAD Refs.Log(headRef).Append(commit.Id, reflogMessage, commit.Committer); }
/// <summary> /// Sets the current <see cref="Head"/> to the specified commit and optionally resets the <see cref="Index"/> and /// the content of the working tree to match. /// </summary> /// <param name="resetOptions">Flavor of reset operation to perform.</param> /// <param name="commit">The target commit object.</param> public void Reset(ResetOptions resetOptions, Commit commit) { Ensure.ArgumentNotNull(commit, "commit"); Proxy.git_reset(handle, commit.Id, resetOptions); Refs.Log(Refs.Head).Append(commit.Id, string.Format("reset: moving to {0}", commit.Sha)); }
private void LogCheckout(string previousHeadName, ObjectId newHeadTip, string newHeadSpec) { // Compute reflog message string reflogMessage = string.Format("checkout: moving from {0} to {1}", previousHeadName, newHeadSpec); // Log checkout Refs.Log(Refs.Head).Append(newHeadTip, reflogMessage); }