/// <summary> /// Internal implementation of Checkout that expects the ID of the checkout target /// to already be in the form of a canonical branch name or a commit ID. /// </summary> /// <param name="tree">The <see cref="Tree"/> to checkout.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> /// <param name="headTarget">Target for the new HEAD.</param> /// <param name="refLogHeadSpec">The spec which will be written as target in the reflog.</param> /// <param name="writeReflogEntry">Will a reflog entry be created.</param> private void Checkout( Tree tree, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions, string headTarget, string refLogHeadSpec, bool writeReflogEntry) { var previousHeadName = Info.IsHeadDetached ? Head.Tip.Sha : Head.Name; var opts = new CheckoutOptions { CheckoutModifiers = checkoutModifiers, OnCheckoutProgress = onCheckoutProgress, CheckoutNotificationOptions = checkoutNotificationOptions }; CheckoutTree(tree, null, opts); Refs.UpdateTarget("HEAD", headTarget); if (writeReflogEntry) { LogCheckout(previousHeadName, Head.Tip.Id, refLogHeadSpec); } }
/// <summary> /// Checkout the specified tree. /// </summary> /// <param name="tree">The <see cref="Tree"/> to checkout.</param> /// <param name="paths">The paths to checkout.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> private void CheckoutTree( Tree tree, IList <string> paths, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { CheckoutNotifyHandler onCheckoutNotify = checkoutNotificationOptions != null ? checkoutNotificationOptions.CheckoutNotifyHandler : null; CheckoutNotifyFlags checkoutNotifyFlags = checkoutNotificationOptions != null ? checkoutNotificationOptions.NotifyFlags : default(CheckoutNotifyFlags); CheckoutCallbacks checkoutCallbacks = CheckoutCallbacks.GenerateCheckoutCallbacks(onCheckoutProgress, onCheckoutNotify); GitStrArrayIn strArray = (paths != null && paths.Count > 0) ? GitStrArrayIn.BuildFrom(ToFilePaths(paths)) : null; GitCheckoutOpts options = new GitCheckoutOpts { version = 1, checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_SAFE, progress_cb = checkoutCallbacks.CheckoutProgressCallback, notify_cb = checkoutCallbacks.CheckoutNotifyCallback, notify_flags = checkoutNotifyFlags, paths = strArray }; try { if (checkoutModifiers.HasFlag(CheckoutModifiers.Force)) { options.checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_FORCE; } Proxy.git_checkout_tree(Handle, tree.Id, ref options); } finally { options.Dispose(); } }
public Branch Checkout(Commit commit, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions, Signature signature = null) { throw new NotImplementedException(); }
/// <summary> /// Checkout the tip commit of this <see cref="Branch"/> object /// with a callback for progress reporting. If this commit is the /// current tip of the branch, will checkout the named branch. Otherwise, /// will checkout the tip commit as a detached HEAD. /// </summary> /// <param name="checkoutModifiers">Options controlling checkout behavior.</param> /// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> public virtual void Checkout(CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { repo.Checkout(this, checkoutModifiers, onCheckoutProgress, checkoutNotificationOptions); }
public virtual void Checkout(CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { var options = new CheckoutOptions { CheckoutModifiers = checkoutModifiers, OnCheckoutProgress = onCheckoutProgress, }; if (checkoutNotificationOptions != null) { options.OnCheckoutNotify = checkoutNotificationOptions.CheckoutNotifyHandler; options.CheckoutNotifyFlags = checkoutNotificationOptions.NotifyFlags; } Checkout(options, null); }
/// <summary> /// Checkout the specified <see cref="LibGit2Sharp.Commit"/>. /// <para> /// Will detach the HEAD and make it point to this commit sha. /// </para> /// </summary> /// <param name="commit">The <see cref="LibGit2Sharp.Commit"/> to check out.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> /// <returns>The <see cref="Branch"/> that was checked out.</returns> public Branch Checkout(Commit commit, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { Checkout(commit.Tree, checkoutModifiers, onCheckoutProgress, checkoutNotificationOptions, commit.Id.Sha, commit.Id.Sha, true); return(Head); }
/// <summary> /// Checkout the tip commit of the specified <see cref="Branch"/> object. If this commit is the /// current tip of the branch, will checkout the named branch. Otherwise, will checkout the tip commit /// as a detached HEAD. /// </summary> /// <param name="branch">The <see cref="Branch"/> to check out.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> /// <returns>The <see cref="Branch"/> that was checked out.</returns> public Branch Checkout(Branch branch, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { Ensure.ArgumentNotNull(branch, "branch"); // Make sure this is not an unborn branch. if (branch.Tip == null) { throw new UnbornBranchException( string.Format(CultureInfo.InvariantCulture, "The tip of branch '{0}' is null. There's nothing to checkout.", branch.Name)); } var branchIsCurrentRepositoryHead = branch.IsCurrentRepositoryHead; if (!branch.IsRemote && !(branch is DetachedHead) && string.Equals(Refs[branch.CanonicalName].TargetIdentifier, branch.Tip.Id.Sha, StringComparison.OrdinalIgnoreCase)) { Checkout(branch.Tip.Tree, checkoutModifiers, onCheckoutProgress, checkoutNotificationOptions, branch.CanonicalName, branch.Name, !branchIsCurrentRepositoryHead); } else { Checkout(branch.Tip.Tree, checkoutModifiers, onCheckoutProgress, checkoutNotificationOptions, branch.Tip.Id.Sha, branch.Name, !branchIsCurrentRepositoryHead); } return(Head); }
/// <summary> /// Checkout the specified <see cref="Branch"/>, reference or SHA. /// <para> /// If the committishOrBranchSpec parameter resolves to a branch name, then the checked out HEAD will /// will point to the branch. Otherwise, the HEAD will be detached, pointing at the commit sha. /// </para> /// </summary> /// <param name="committishOrBranchSpec">A revparse spec for the commit or branch to checkout.</param> /// <param name="checkoutModifiers"><see cref="CheckoutModifiers"/> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that checkout progress is reported through.</param> /// <param name="checkoutNotifications"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> /// <returns>The <see cref="Branch"/> that was checked out.</returns> public Branch Checkout(string committishOrBranchSpec, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotifications) { Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec"); var handles = Proxy.git_revparse_ext(Handle, committishOrBranchSpec); if (handles == null) { Ensure.GitObjectIsNotNull(null, committishOrBranchSpec); } var objH = handles.Item1; var refH = handles.Item2; GitObject obj; try { if (!refH.IsInvalid) { var reference = Reference.BuildFromPtr <Reference>(refH, this); if (reference.IsLocalBranch()) { Branch branch = Branches[reference.CanonicalName]; return(Checkout(branch, checkoutModifiers, onCheckoutProgress, checkoutNotifications)); } } obj = GitObject.BuildFrom(this, Proxy.git_object_id(objH), Proxy.git_object_type(objH), PathFromRevparseSpec(committishOrBranchSpec)); } finally { objH.Dispose(); refH.Dispose(); } Commit commit = obj.DereferenceToCommit(true); Checkout(commit.Tree, checkoutModifiers, onCheckoutProgress, checkoutNotifications, commit.Id.Sha, committishOrBranchSpec, committishOrBranchSpec != "HEAD"); return(Head); }
public Branch Checkout(string committishOrBranchSpec, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { throw new System.NotImplementedException(); }
public Branch Checkout(Branch branch, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { throw new System.NotImplementedException(); }
public void CheckoutPaths(string committishOrBranchSpec, IList<string> paths, CheckoutModifiers checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { throw new System.NotImplementedException(); }
public void CheckoutPaths(string committishOrBranchSpec, IList <string> paths, CheckoutModifiers checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { var opts = new CheckoutOptions { CheckoutModifiers = checkoutOptions, OnCheckoutProgress = onCheckoutProgress, CheckoutNotificationOptions = checkoutNotificationOptions }; CheckoutPaths(committishOrBranchSpec, paths, opts); }
/// <summary> /// Updates specifed paths in the index and working directory with the versions from the specified branch, reference, or SHA. /// <para> /// This method does not switch branches or update the current repository HEAD. /// </para> /// </summary> /// <param name="committishOrBranchSpec">A revparse spec for the commit or branch to checkout paths from.</param> /// <param name="paths">The paths to checkout.</param> /// <param name="checkoutOptions">Options controlling checkout behavior.</param> /// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param> /// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param> public void CheckoutPaths(string committishOrBranchSpec, IList <string> paths, CheckoutModifiers checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions) { Ensure.ArgumentNotNullOrEmptyString(committishOrBranchSpec, "committishOrBranchSpec"); Commit commit = LookupCommit(committishOrBranchSpec); CheckoutTree(commit.Tree, paths, checkoutOptions, onCheckoutProgress, checkoutNotificationOptions); }