diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-01-23 17:58:20 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2013-01-23 21:15:11 +0400 |
commit | 1ccfc718b8e2919430b2942a6c1c14cb1284029d (patch) | |
tree | ac978e39dd51dd684062f0c08c37c9f66c36b4ad /LibGit2Sharp.Tests/CheckoutFixture.cs | |
parent | 80dcc97f83e2c7183328d9f813f3f870bb35af79 (diff) |
Ensure Checkout() doesn't mess with binary files
Fix #302
Diffstat (limited to 'LibGit2Sharp.Tests/CheckoutFixture.cs')
-rw-r--r-- | LibGit2Sharp.Tests/CheckoutFixture.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs index 97738b49..244b7ce0 100644 --- a/LibGit2Sharp.Tests/CheckoutFixture.cs +++ b/LibGit2Sharp.Tests/CheckoutFixture.cs @@ -573,6 +573,33 @@ namespace LibGit2Sharp.Tests } } + [Fact] + public void CheckingOutABranchDoesNotAlterBinaryFiles() + { + TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath); + using (var repo = new Repository(path.RepositoryPath)) + { + // $ git hash-object azure3.png + // be5028b2f245165f015927020e41247f8a3c0dfe + const string expectedSha = "be5028b2f245165f015927020e41247f8a3c0dfe"; + + // The blob actually exists in the object database with the correct Sha + Assert.Equal(expectedSha, repo.Lookup<Blob>(expectedSha).Sha); + + repo.Checkout("refs/heads/logo", + CheckoutOptions.Force, null); + + // The Index has been updated as well with the blob + Assert.Equal(expectedSha, repo.Index["azure3.png"].Id.Sha); + + // Recreating a Blob from the checked out file... + Blob blob = repo.ObjectDatabase.CreateBlob("azure3.png"); + + // ...generates the same Sha + Assert.Equal(expectedSha, blob.Id.Sha); + } + } + /// <summary> /// Helper method to populate a simple repository with /// a single file and two branches. |