using LibGit2Sharp.Core; using LibGit2Sharp.Handlers; namespace LibGit2Sharp { /// /// Options controlling CherryPick behavior. /// public sealed class CherryPickOptions : IConvertableToGitCheckoutOpts { /// /// Initializes a new instance of the class. /// By default the cherry pick will be committed if there are no conflicts. /// public CherryPickOptions() { CommitOnSuccess = true; FindRenames = true; // TODO: libgit2 should provide reasonable defaults for these // values, but it currently does not. RenameThreshold = 50; TargetLimit = 200; } /// /// The Flags specifying what conditions are /// reported through the OnCheckoutNotify delegate. /// public CheckoutNotifyFlags CheckoutNotifyFlags { get; set; } /// /// Delegate that checkout progress will be reported through. /// public CheckoutProgressHandler OnCheckoutProgress { get; set; } /// /// Delegate that checkout will notify callers of /// certain conditions. The conditions that are reported is /// controlled with the CheckoutNotifyFlags property. /// public CheckoutNotifyHandler OnCheckoutNotify { get; set; } /// /// Commit the cherry pick if the cherry pick is successful. /// public bool CommitOnSuccess { get; set; } /// /// When cherry picking a merge commit, the parent number to consider as /// mainline, starting from offset 1. /// /// As a merge commit has multiple parents, cherry picking a merge commit /// will reverse all the changes brought in by the merge except for /// one parent's line of commits. The parent to preserve is called the /// mainline, and must be specified by its number (i.e. offset). /// /// public int Mainline { get; set; } /// /// How to handle conflicts encountered during a merge. /// public MergeFileFavor MergeFileFavor { get; set; } /// /// How Checkout should handle writing out conflicting index entries. /// public CheckoutFileConflictStrategy FileConflictStrategy { get; set; } /// /// Find renames. Default is true. /// public bool FindRenames { get; set; } /// /// Similarity to consider a file renamed (default 50). If /// `FindRenames` is enabled, added files will be compared /// with deleted files to determine their similarity. Files that are /// more similar than the rename threshold (percentage-wise) will be /// treated as a rename. /// public int RenameThreshold; /// /// Maximum similarity sources to examine for renames (default 200). /// If the number of rename candidates (add / delete pairs) is greater /// than this value, inexact rename detection is aborted. /// /// This setting overrides the `merge.renameLimit` configuration value. /// public int TargetLimit; #region IConvertableToGitCheckoutOpts CheckoutCallbacks IConvertableToGitCheckoutOpts.GenerateCallbacks() { return CheckoutCallbacks.From(OnCheckoutProgress, OnCheckoutNotify); } CheckoutStrategy IConvertableToGitCheckoutOpts.CheckoutStrategy { get { return CheckoutStrategy.GIT_CHECKOUT_SAFE | GitCheckoutOptsWrapper.CheckoutStrategyFromFileConflictStrategy(FileConflictStrategy); } } #endregion IConvertableToGitCheckoutOpts } }