/// <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="opts">Collection of parameters controlling checkout behavior.</param> private void CheckoutTree( Tree tree, IList <string> paths, CheckoutOptions opts) { CheckoutNotifyHandler onCheckoutNotify = opts.CheckoutNotificationOptions != null ? opts.CheckoutNotificationOptions.CheckoutNotifyHandler : null; CheckoutNotifyFlags checkoutNotifyFlags = opts.CheckoutNotificationOptions != null ? opts.CheckoutNotificationOptions.NotifyFlags : default(CheckoutNotifyFlags); CheckoutCallbacks checkoutCallbacks = CheckoutCallbacks.GenerateCheckoutCallbacks(opts.OnCheckoutProgress, onCheckoutNotify); GitStrArrayIn strArray = (paths != null && paths.Count > 0) ? GitStrArrayIn.BuildFrom(ToFilePaths(paths)) : null; var 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 (opts.CheckoutModifiers.HasFlag(CheckoutModifiers.Force)) { options.checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_FORCE; } Proxy.git_checkout_tree(Handle, tree.Id, ref options); } finally { options.Dispose(); } }
/// <summary> /// Clean the working tree by removing files that are not under version control. /// </summary> public virtual void RemoveUntrackedFiles() { var options = new GitCheckoutOpts { version = 1, checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_REMOVE_UNTRACKED | CheckoutStrategy.GIT_CHECKOUT_ALLOW_CONFLICTS, }; Proxy.git_checkout_index(Handle, new NullGitObjectSafeHandle(), ref options); }
/// <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="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param> /// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param> private void CheckoutTree(Tree tree, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress) { GitCheckoutOpts options = new GitCheckoutOpts { version = 1, checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_SAFE, progress_cb = CheckoutCallbacks.GenerateCheckoutCallbacks(onCheckoutProgress) }; if (checkoutOptions.HasFlag(CheckoutOptions.Force)) { options.checkout_strategy = CheckoutStrategy.GIT_CHECKOUT_FORCE; } Proxy.git_checkout_tree(this.Handle, tree.Id, ref options); }