325
325
/// <exception cref="System.IO.IOException"></exception>
326
326
[NUnit.Framework.Test]
327
public virtual void TestReadNotExistingBranchConfig()
329
NUnit.Framework.Assert.IsNull(refdir.GetRef("config"), "find branch config");
330
NUnit.Framework.Assert.IsNull(refdir.GetRef("refs/heads/config"), "find branch config"
334
/// <exception cref="System.IO.IOException"></exception>
335
[NUnit.Framework.Test]
336
public virtual void TestReadBranchConfig()
338
WriteLooseRef("refs/heads/config", A);
339
NUnit.Framework.Assert.IsNotNull(refdir.GetRef("config"), "find branch config");
342
/// <exception cref="System.IO.IOException"></exception>
343
[NUnit.Framework.Test]
327
344
public virtual void TestGetRefs_HeadsOnly_AllLoose()
329
346
IDictionary<string, Ref> heads;
833
850
NUnit.Framework.Assert.AreEqual(v1_0.GetObject(), tag.GetPeeledObjectId());
853
/// <exception cref="System.Exception"></exception>
854
[NUnit.Framework.Test]
855
public virtual void Test_repack()
857
IDictionary<string, Ref> all;
858
WritePackedRefs("# pack-refs with: peeled \n" + A.Name + " refs/heads/master\n" +
859
B.Name + " refs/heads/other\n" + v1_0.Name + " refs/tags/v1.0\n" + "^" + v1_0.GetObject
865
all = refdir.GetRefs(RefDatabase.ALL);
866
NUnit.Framework.Assert.AreEqual(4, all.Count);
867
NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, all.Get(Constants.HEAD).GetStorage
869
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/heads/master").GetStorage
871
NUnit.Framework.Assert.AreEqual(A.Id, all.Get("refs/heads/master").GetObjectId());
872
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/heads/other").GetStorage
874
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/tags/v1.0").GetStorage
876
repo.Update("refs/heads/master", B.Id);
877
RevTag v0_1 = repo.Tag("v0.1", A);
878
repo.Update("refs/tags/v0.1", v0_1);
879
all = refdir.GetRefs(RefDatabase.ALL);
880
NUnit.Framework.Assert.AreEqual(5, all.Count);
881
NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, all.Get(Constants.HEAD).GetStorage
883
// Why isn't the next ref LOOSE_PACKED?
884
NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, all.Get("refs/heads/master").GetStorage
886
NUnit.Framework.Assert.AreEqual(B.Id, all.Get("refs/heads/master").GetObjectId());
887
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/heads/other").GetStorage
889
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/tags/v1.0").GetStorage
891
NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, all.Get("refs/tags/v0.1").GetStorage
893
NUnit.Framework.Assert.AreEqual(v0_1.Id, all.Get("refs/tags/v0.1").GetObjectId());
894
all = refdir.GetRefs(RefDatabase.ALL);
895
refdir.Pack(new AList<string>(all.Keys));
896
all = refdir.GetRefs(RefDatabase.ALL);
897
NUnit.Framework.Assert.AreEqual(5, all.Count);
898
NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, all.Get(Constants.HEAD).GetStorage
900
// Why isn't the next ref LOOSE_PACKED?
901
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/heads/master").GetStorage
903
NUnit.Framework.Assert.AreEqual(B.Id, all.Get("refs/heads/master").GetObjectId());
904
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/heads/other").GetStorage
906
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/tags/v1.0").GetStorage
908
NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, all.Get("refs/tags/v0.1").GetStorage
910
NUnit.Framework.Assert.AreEqual(v0_1.Id, all.Get("refs/tags/v0.1").GetObjectId());
836
913
/// <exception cref="System.IO.IOException"></exception>
837
914
[NUnit.Framework.Test]
838
915
public virtual void TestGetRef_EmptyDatabase()
1027
1104
NUnit.Framework.Assert.AreSame(master_p2, refdir.Peel(master_p2));
1107
/// <exception cref="System.Exception"></exception>
1108
[NUnit.Framework.Test]
1109
public virtual void TestRefsChangedStackOverflow()
1111
FileRepository newRepo = CreateBareRepository();
1112
RefDatabase refDb = newRepo.RefDatabase;
1113
FilePath packedRefs = new FilePath(newRepo.Directory, "packed-refs");
1114
NUnit.Framework.Assert.IsTrue(packedRefs.CreateNewFile());
1115
AtomicReference<StackOverflowError> error = new AtomicReference<StackOverflowError
1117
AtomicReference<IOException> exception = new AtomicReference<IOException>();
1118
AtomicInteger changeCount = new AtomicInteger();
1119
newRepo.Listeners.AddRefsChangedListener(new _RefsChangedListener_1156(refDb, changeCount
1120
, error, exception));
1121
refDb.GetRefs("ref");
1122
refDb.GetRefs("ref");
1123
NUnit.Framework.Assert.IsNull(error.Get());
1124
NUnit.Framework.Assert.IsNull(exception.Get());
1125
NUnit.Framework.Assert.AreEqual(1, changeCount.Get());
1128
private sealed class _RefsChangedListener_1156 : RefsChangedListener
1130
public _RefsChangedListener_1156(RefDatabase refDb, AtomicInteger changeCount, AtomicReference
1131
<StackOverflowError> error, AtomicReference<IOException> exception)
1134
this.changeCount = changeCount;
1136
this.exception = exception;
1139
public void OnRefsChanged(RefsChangedEvent @event)
1143
refDb.GetRefs("ref");
1144
changeCount.IncrementAndGet();
1146
catch (StackOverflowError soe)
1150
catch (IOException ioe)
1156
private readonly RefDatabase refDb;
1158
private readonly AtomicInteger changeCount;
1160
private readonly AtomicReference<StackOverflowError> error;
1162
private readonly AtomicReference<IOException> exception;
1030
1165
/// <exception cref="System.IO.IOException"></exception>
1031
1166
private void WriteLooseRef(string name, AnyObjectId id)