8000 Rebase: introduce a Rebase class · libgit2/libgit2sharp@e7254b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e7254b8

Browse files
committed
Rebase: introduce a Rebase class
Introduce a Rebase class that maps to the rebase object in libgit2 more directly.
1 parent 75dad9b commit e7254b8

File tree

8 files changed

+136
-292
lines changed

8 files changed

+136
-292
lines changed

LibGit2Sharp/Commands/Rebase.cs

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,6 @@ public static partial class Commands
1212
/// </summary>
1313
public static class Rebase
1414
{
15-
/// <summary>
16-
/// The type of operation to be performed in a rebase step.
17-
/// </summary>
18-
public enum RebaseStepOperation
19-
{
20-
/// <summary>
21-
/// Commit is to be cherry-picked.
22-
/// </summary>
23-
Pick = 0,
24-
25-
/// <summary>
26-
/// Cherry-pick the commit and edit the commit message.
27-
/// </summary>
28-
Reword,
29-
30-
/// <summary>
31-
/// Cherry-pick the commit but allow user to edit changes.
32-
/// </summary>
33-
Edit,
34-
35-
/// <summary>
36-
/// Commit is to be squashed into previous commit. The commit
37-
/// message will be merged with the previous message.
38-
/// </summary>
39-
Squash,
40-
41-
/// <summary>
42-
/// Commit is to be squashed into previous commit. The commit
43-
/// message will be discarded.
44-
/// </summary>
45-
Fixup,
46-
47-
// <summary>
48-
// No commit to cherry-pick. Run the given command and continue
49-
// if successful.
50-
// </summary>
51-
// Exec
52-
}
53-
5415
private unsafe static AnnotatedCommitHandle AnnotatedCommitHandleFromRefHandle(Repository repository, ReferenceHandle refHandle)
5516
{
5617
return (refHandle == null) ?
@@ -70,6 +31,7 @@ private unsafe static AnnotatedCommitHandle AnnotatedCommitHandleFromRefHandle(R
7031
/// <returns>true if completed successfully, false if conflicts encountered.</returns>
7132
public static RebaseResult Start(Repository repository, Branch branch, Branch upstream, Branch onto, Identity committer, RebaseOptions options)
7233
{
34+
Ensure.ArgumentNotNull(repository, "repository");
7335
Ensure.ArgumentNotNull(upstream, "upstream");
7436

7537
options = options ?? new RebaseOptions();
@@ -145,7 +107,7 @@ public static unsafe RebaseResult Continue(Repository repository, Identity commi
145107
// TODO: Should we check the pre-conditions for committing here
146108
// for instance - what if we had failed on the git_rebase_finish call,
147109
// do we want continue to be able to restart afterwords...
148-
var rebaseCommitResult = Proxy.git_rebase_commit(rebase, null, committer);
110+
var rebaseCommitResult = Proxy.git_rebase_commit(rebase, null, committer, null);
149111

150112
// Report that we just completed the step
151113
if (options.RebaseStepCompleted != null)

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ internal static extern unsafe int git_rebase_commit(
208208
git_rebase* rebase,
209209
git_signature* author,
210210
git_signature* committer,
211-
IntPtr message_encoding,
212-
IntPtr message);
211+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message_encoding,
212+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message);
213213

214214
[DllImport(libgit2)]
215215
internal static extern unsafe int git_rebase_abort(

LibGit2Sharp/Core/Proxy.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,8 @@ private static UIntPtr GIT_REBASE_NO_OPERATION
17921792
public static unsafe GitRebaseCommitResult git_rebase_commit(
17931793
RebaseHandle rebase,
17941794
Identity author,
1795-
Identity committer)
1795+
Identity committer,
1796+
string message)
17961797
{
17971798
Ensure.ArgumentNotNull(rebase, "rebase");
17981799
Ensure.ArgumentNotNull(committer, "committer");
@@ -1802,7 +1803,7 @@ public static unsafe GitRebaseCommitResult git_rebase_commit(
18021803
{
18031804
GitRebaseCommitResult commitResult = new GitRebaseCommitResult();
18041805

1805-
int result = NativeMethods.git_rebase_commit(ref commitResult.CommitId, rebase, authorHandle, committerHandle, IntPtr.Zero, IntPtr.Zero);
1806+
int result = NativeMethods.git_rebase_commit(ref commitResult.CommitId, rebase, authorHandle, committerHandle, null, message);
18061807

18071808
if (result == (int)GitErrorCode.Applied)
18081809
{

LibGit2Sharp/ObjectDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ public virtual MergeTreeResult MergeCommits(Commit ours, Commit theirs, MergeTre
819819
return mergeResult;
820820
}
821821
}
822-
822+
823823
/// <summary>
824824
/// Packs all the objects in the <see cref="ObjectDatabase"/> and write a pack (.pack) and index (.idx) files for them.
825825
/// </summary>

0 commit comments

Comments
 (0)
0