Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2015-05-09 18:50:15 +0300
committernulltoken <emeric.fermas@gmail.com>2015-05-09 18:58:52 +0300
commit59eb6c80c110d0a1ecc6869ff093806f6c56df5c (patch)
tree3722fce7ce2d8e6c5dac6dbcbecbfb725995518e
parent296aa06cb9709d49505be7114651b2239d7ad738 (diff)
Silently ignore rewriting of commits under refs/notes/*
Fix #942
-rw-r--r--LibGit2Sharp.Tests/FilterBranchFixture.cs23
-rw-r--r--LibGit2Sharp/Core/HistoryRewriter.cs6
2 files changed, 27 insertions, 2 deletions
diff --git a/LibGit2Sharp.Tests/FilterBranchFixture.cs b/LibGit2Sharp.Tests/FilterBranchFixture.cs
index dfe14329..aed628a1 100644
--- a/LibGit2Sharp.Tests/FilterBranchFixture.cs
+++ b/LibGit2Sharp.Tests/FilterBranchFixture.cs
@@ -162,7 +162,8 @@ namespace LibGit2Sharp.Tests
AssertSucceedingButNotError();
- var nonBackedUpRefs = repo.Refs.Where(x => !x.CanonicalName.StartsWith("refs/original"));
+ var nonBackedUpRefs = repo.Refs.Where(
+ x => !x.CanonicalName.StartsWith("refs/original/") && !x.CanonicalName.StartsWith("refs/notes/"));
Assert.Empty(repo.Commits.QueryBy(new CommitFilter { Since = nonBackedUpRefs })
.Where(c => c.Author.Name != "Ben Straub"));
}
@@ -801,6 +802,26 @@ namespace LibGit2Sharp.Tests
Assert.Equal(annotationB, backedUpTag.ResolveToDirectReference().Target);
}
+ [Fact]
+ public void RewritingNotesHasNoEffect()
+ {
+ var notesRefsRetriever = new Func<IEnumerable<Reference>>(() => repo.Refs.Where(r => r.CanonicalName.StartsWith("refs/notes/")));
+ var originalNotesRefs = notesRefsRetriever().ToList();
+ var commits = repo.Commits.QueryBy(new CommitFilter { Since = originalNotesRefs }).ToArray();
+
+ repo.Refs.RewriteHistory(new RewriteHistoryOptions
+ {
+ OnError = OnError,
+ OnSucceeding = OnSucceeding,
+ CommitHeaderRewriter =
+ c => CommitRewriteInfo.From(c, author: Constants.Signature),
+ }, commits);
+
+ AssertSucceedingButNotError();
+
+ Assert.Equal(originalNotesRefs.OrderBy(r => r.CanonicalName), notesRefsRetriever().OrderBy(r => r.CanonicalName));
+ }
+
private static string TagNameRewriter(string name, bool isAnnotated, string target)
{
const string tagPrefix = "refs/tags/";
diff --git a/LibGit2Sharp/Core/HistoryRewriter.cs b/LibGit2Sharp/Core/HistoryRewriter.cs
index 15686ecc..d520b3c2 100644
--- a/LibGit2Sharp/Core/HistoryRewriter.cs
+++ b/LibGit2Sharp/Core/HistoryRewriter.cs
@@ -59,7 +59,11 @@ namespace LibGit2Sharp.Core
// before A.
foreach (var reference in refsToRewrite.OrderBy(ReferenceDepth))
{
- // TODO: Check how rewriting of notes actually behaves
+ // TODO: Rewrite refs/notes/* properly
+ if (reference.CanonicalName.StartsWith("refs/notes/"))
+ {
+ continue;
+ }
RewriteReference(reference);
}