Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IndexAdd doesn't produce a valid index. In order to help troubleshoot…

… the issue, added a IndexAddThroughCore() test method which produces a valid index readable by msysgit.
  • Loading branch information...
commit 0b0eee7fe9ac4669d0292a132b4fa29e1542d44e 1 parent 63ec1c1
@nulltoken nulltoken authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 Tests/API/IndexTest.cs
View
38 Tests/API/IndexTest.cs
@@ -40,6 +40,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using GitSharp.Core;
using NUnit.Framework;
using GitSharp.Tests;
using System.IO;
@@ -80,6 +81,43 @@ public void IndexAdd()
}
[Test]
+ public void IndexAddThroughCore()
+ {
+ var workingDirectory = Path.Combine(trash.FullName, "test");
+ var gitRepo = Repository.Init(workingDirectory);
+
+ var index_path = Path.Combine(gitRepo.Directory, "index");
+ var old_index = Path.Combine(gitRepo.Directory, "old_index");
+
+ var repo = new GitSharp.Core.Repository(new DirectoryInfo(workingDirectory + "/.git"));
+
+ var index = repo.Index;
+ index.write(); // write empty index
+ new FileInfo(index_path).CopyTo(old_index);
+ string filepath = Path.Combine(workingDirectory, "for henon.txt");
+ File.WriteAllText(filepath, "Weißbier");
+ repo.Index.add(new DirectoryInfo(workingDirectory), new FileInfo(filepath));
+ repo.Index.write();
+ // now verify
+ Assert.IsTrue(new FileInfo(index_path).Exists);
+ var new_index = new GitSharp.Core.Repository(repo.Directory).Index;
+ Assert.AreNotEqual(File.ReadAllBytes(old_index), File.ReadAllBytes(index_path));
+
+ // make another addition
+ var index_1 = Path.Combine(gitRepo.Directory, "index_1");
+ new FileInfo(index_path).CopyTo(index_1);
+ string filepath1 = Path.Combine(workingDirectory, "for nulltoken.txt");
+ File.WriteAllText(filepath1, "Rotwein");
+ index = new GitIndex(repo);
+ index.Read();
+ index.add(new DirectoryInfo(workingDirectory), new FileInfo(filepath1));
+ index.write();
+ Assert.AreNotEqual(File.ReadAllBytes(index_1), File.ReadAllBytes(index_path));
+ Assert.DoesNotThrow(() => repo.Index.Read());
+ // todo: get changes and verify that for henon.txt has been added
+ }
+
+ [Test]
public void Read_write_empty_index()
{
var repo = GetTrashRepository();
Please sign in to comment.
Something went wrong with that request. Please try again.