/// <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> /// Generate a delegate matching the signature of the native progress_cb callback and wraps the <see cref="CheckoutProgressHandler"/> delegate. /// </summary> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that should be wrapped in the native callback.</param> /// <param name="onCheckoutNotify"><see cref="CheckoutNotifyHandler"/> delegate to call in response to checkout notification callback.</param> /// <returns>The delegate with signature matching the expected native callback.</returns> internal static CheckoutCallbacks From(CheckoutProgressHandler onCheckoutProgress, CheckoutNotifyHandler onCheckoutNotify) { return new CheckoutCallbacks(onCheckoutProgress, onCheckoutNotify); }
/// <summary> /// Constructor to set up native callback for given managed delegate. /// </summary> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> delegate to call in response to checkout progress_cb</param> /// <param name="onCheckoutNotify"><see cref="CheckoutNotifyHandler"/> delegate to call in response to checkout notification callback.</param> private CheckoutCallbacks(CheckoutProgressHandler onCheckoutProgress, CheckoutNotifyHandler onCheckoutNotify) { this.onCheckoutProgress = onCheckoutProgress; this.onCheckoutNotify = onCheckoutNotify; }
/// <summary> /// Construct the CheckoutNotificationOptions class. /// </summary> /// <param name="checkoutNotifyHandler"><see cref="CheckoutNotifyHandler"/> that checkout notifications are reported through.</param> /// <param name="notifyFlags">The checkout notification type.</param> public CheckoutNotificationOptions(CheckoutNotifyHandler checkoutNotifyHandler, CheckoutNotifyFlags notifyFlags) { CheckoutNotifyHandler = checkoutNotifyHandler; NotifyFlags = notifyFlags; }
/// <summary> /// Construct the CheckoutNotificationOptions class. /// </summary> /// <param name="checkoutNotifyHandler"><see cref="CheckoutNotifyHandler"/> that checkout notifications are reported through.</param> /// <param name="notifyFlags">The checkout notification type.</param> public CheckoutNotificationOptions(CheckoutNotifyHandler checkoutNotifyHandler, CheckoutNotifyFlags notifyFlags) { CheckoutNotifyHandler = checkoutNotifyHandler; NotifyFlags = notifyFlags; }
/// <summary> /// Generate a delegate matching the signature of the native progress_cb callback and wraps the <see cref="CheckoutProgressHandler"/> delegate. /// </summary> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> that should be wrapped in the native callback.</param> /// <param name="onCheckoutNotify"><see cref="CheckoutNotifyHandler"/> delegate to call in response to checkout notification callback.</param> /// <returns>The delegate with signature matching the expected native callback.</returns> internal static CheckoutCallbacks GenerateCheckoutCallbacks(CheckoutProgressHandler onCheckoutProgress, CheckoutNotifyHandler onCheckoutNotify) { return(new CheckoutCallbacks(onCheckoutProgress, onCheckoutNotify)); }
/// <summary> /// Constructor to set up native callback for given managed delegate. /// </summary> /// <param name="onCheckoutProgress"><see cref="CheckoutProgressHandler"/> delegate to call in response to checkout progress_cb</param> /// <param name="onCheckoutNotify"><see cref="CheckoutNotifyHandler"/> delegate to call in response to checkout notification callback.</param> private CheckoutCallbacks(CheckoutProgressHandler onCheckoutProgress, CheckoutNotifyHandler onCheckoutNotify) { this.onCheckoutProgress = onCheckoutProgress; this.onCheckoutNotify = onCheckoutNotify; }