Skip to content

Commit c696680

Browse files
committed
Fixup: tweaks and code review feedback
1 parent 368a0a8 commit c696680

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@
158158
<Target Name="AfterBuild">
159159
</Target>
160160
-->
161-
</Project>
161+
</Project>

LibGit2Sharp.Tests/RebaseFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void CanRebase(string initialBranchName,
8989

9090
// Verify the chain of commits that resulted from the rebase.
9191
Commit expectedParent = expectedOntoCommit;
92-
foreach(CompletedRebaseStepInfo stepInfo in PostRebaseResults)
92+
foreach (CompletedRebaseStepInfo stepInfo in PostRebaseResults)
9393
{
9494
Commit rebasedCommit = stepInfo.Commit;
9595
Assert.Equal(expectedParent.Id, rebasedCommit.Parents.First().Id);
@@ -113,7 +113,7 @@ public CompletedRebaseStepInfo(Commit commit, bool wasPatchAlreadyApplied)
113113

114114
public bool WasPatchAlreadyApplied { get; set; }
115115

116-
public override string ToString()
116+
public override string ToString()
117117
{
118118
return string.Format("CompletedRebaseStepInfo: {0}", Commit);
119119
}
@@ -128,8 +128,8 @@ bool IEqualityComparer<CompletedRebaseStepInfo>.Equals(CompletedRebaseStepInfo x
128128
return true;
129129
}
130130

131-
if ((x == null && y != null ) ||
132-
(x != null && y == null ))
131+
if ((x == null && y != null) ||
132+
(x != null && y == null))
133133
{
134134
return false;
135135
}

LibGit2Sharp/Core/Proxy.cs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,28 +1654,28 @@ public static RebaseSafeHandle git_rebase_init(
16541654
GitAnnotatedCommitHandle onto,
16551655
ref GitRebaseOptions options)
16561656
{
1657-
RebaseSafeHandle rebase = null;
1658-
16591657
using (ThreadAffinity())
16601658
{
1659+
RebaseSafeHandle rebase = null;
1660+
16611661
int result = NativeMethods.git_rebase_init(out rebase, repo, branch, upstream, onto, ref options);
16621662
Ensure.ZeroResult(result);
1663-
}
16641663

1665-
return rebase;
1664+
return rebase;
1665+
}
16661666
}
16671667

16681668
public static RebaseSafeHandle git_rebase_open(RepositorySafeHandle repo)
16691669
{
1670-
RebaseSafeHandle rebase = null;
1671-
16721670
using (ThreadAffinity())
16731671
{
1672+
RebaseSafeHandle rebase = null;
1673+
16741674
int result = NativeMethods.git_rebase_open(out rebase, repo);
16751675
Ensure.ZeroResult(result);
1676-
}
16771676

1678-
return rebase;
1677+
return rebase;
1678+
}
16791679
}
16801680

16811681
public static long git_rebase_operation_entrycount(RebaseSafeHandle rebase)
@@ -1710,9 +1710,9 @@ public static GitRebaseOperation git_rebase_operation_byindex(
17101710
public static GitRebaseOperation git_rebase_next(RebaseSafeHandle rebase,
17111711
ref GitCheckoutOpts options)
17121712
{
1713-
GitRebaseOperation operation = null;
17141713
using (ThreadAffinity())
17151714
{
1715+
GitRebaseOperation operation = null;
17161716
IntPtr ptr;
17171717
int result = NativeMethods.git_rebase_next(out ptr, rebase, ref options);
17181718
if (result == (int)GitErrorCode.IterOver)
@@ -1726,9 +1726,9 @@ public static GitRebaseOperation git_rebase_next(RebaseSafeHandle rebase,
17261726

17271727
// Workaround until 92e87dd74 from libgit2 is consumed by LibGit2#
17281728
operation.exec = IntPtr.Zero;
1729-
}
17301729

1731-
return operation;
1730+
return operation;
1731+
}
17321732
}
17331733

17341734
public static GitRebaseCommitResult git_rebase_commit(
@@ -1739,28 +1739,26 @@ public static GitRebaseCommitResult git_rebase_commit(
17391739
Ensure.ArgumentNotNull(rebase, "rebase");
17401740
Ensure.ArgumentNotNull(committer, "committer");
17411741

1742-
GitRebaseCommitResult commitResult = new GitRebaseCommitResult();
1743-
1742+
using (ThreadAffinity())
17441743
using (SignatureSafeHandle committerHandle = committer.BuildHandle())
17451744
using (SignatureSafeHandle authorHandle = author.SafeBuildHandle())
17461745
{
1747-
using (ThreadAffinity())
1748-
{
1749-
int result = NativeMethods.git_rebase_commit(ref commitResult.CommitId, rebase, authorHandle, committerHandle, IntPtr.Zero, IntPtr.Zero);
1746+
GitRebaseCommitResult commitResult = new GitRebaseCommitResult();
17501747

1751-
if (result == (int)GitErrorCode.Applied)
1752-
{
1753-
commitResult.CommitId = GitOid.Empty;
1754-
commitResult.WasPatchAlreadyApplied = true;
1755-
}
1756-
else
1757-
{
1758-
Ensure.ZeroResult(result);
1759-
}
1748+
int result = NativeMethods.git_rebase_commit(ref commitResult.CommitId, rebase, authorHandle, committerHandle, IntPtr.Zero, IntPtr.Zero);
1749+
1750+
if (result == (int)GitErrorCode.Applied)
1751+
{
1752+
commitResult.CommitId = GitOid.Empty;
1753+
commitResult.WasPatchAlreadyApplied = true;
1754+
}
1755+
else
1756+
{
1757+
Ensure.ZeroResult(result);
17601758
}
1761-
}
17621759

1763-
return commitResult;
1760+
return commitResult;
1761+
}
17641762
}
17651763

17661764
/// <summary>

LibGit2Sharp/Rebase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ public virtual RebaseResult Continue(Signature committer, RebaseOptions options)
139139

140140
using (RebaseSafeHandle rebase = Proxy.git_rebase_open(repository.Handle))
141141
{
142+
// TODO: Should we check the pre-conditions for committing here
143+
// for instance - what if we had failed on the git_rebase_finish call,
144+
// do we want continue to be able to restart afterwords...
142145
var rebaseCommitResult = Proxy.git_rebase_commit(rebase, null, committer);
143146

144147
// Report that we just completed the step

LibGit2Sharp/RebaseOperationImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ public static RebaseResult Run(RebaseSafeHandle rebaseOperationHandle,
150150
};
151151

152152
// Rebase is completed!
153-
// currentStep is the last completed - increment it to account
154-
// for the fact that we have moved past last step index.
155153
Proxy.git_rebase_finish(rebaseOperationHandle, committer, gitRebaseOptions);
156154
rebaseResult = new RebaseResult(RebaseStatus.Complete,
157155
totalStepCount,

0 commit comments

Comments
 (0)