Skip to content

Bring back some pointers #1247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4f7e628
Handle exceptions and null returns from CredentialsProvider.
chescock Nov 19, 2015
b1f1f47
Use a pointer to retrieve the library's error
carlosmn Dec 11, 2015
c2b73df
Use pointers for retrieving a config entry
carlosmn Dec 11, 2015
e5aa4fb
Use pointers for tree entries
carlosmn Dec 11, 2015
7445d4c
Use pointers for git references
carlosmn Dec 11, 2015
ed25e69
Use pointers for getting the list of advertised refs
carlosmn Dec 12, 2015
92fc8f5
Use pointers to read the index entries
carlosmn Dec 14, 2015
966ec5a
Get rid of the index entry SafeHandle
carlosmn Dec 15, 2015
43521a6
Disentangle the reference and config iterators
carlosmn Dec 16, 2015
690af70
Get rid of the branch iterator SafeHandle
carlosmn Jan 12, 2016
c05ee27
Create handles via templating
carlosmn Jan 13, 2016
5762938
Move git_reference to the template
carlosmn Jan 13, 2016
c0cf249
Get rid of OidSafeHandle
carlosmn Jan 13, 2016
70074f9
Get rid of GitRefSpecHandle
carlosmn Jan 13, 2016
8be1e38
Remove unused TreeEntrySafeHandle
carlosmn Jan 13, 2016
86498c7
Get rid of RepositorySafeHandle
carlosmn Jan 13, 2016
b2d9e44
Set the pointer to null upon disposing
carlosmn Jan 13, 2016
707bbc7
Get rid of IndexNameEntrySafeHandle and IndexReucEntrySafeHandle
carlosmn Jan 13, 2016
1f50a0f
Get rid of StatusEntrySafeHandle
carlosmn Jan 13, 2016
4c5c088
Get rid of SignatureSafeHandle
carlosmn Jan 14, 2016
d3622c3
Get rid of StatusListSafeHandle
carlosmn Jan 14, 2016
b55cd1c
Get rid of the rest of MarshalAs
carlosmn Jan 14, 2016
57a9183
fixup! Move git_reference to the template
carlosmn Jan 15, 2016
1d5b5f5
Get rid of DiffSafeHandle and PatchSafeHandle
carlosmn Jan 15, 2016
4b8b026
Get rid of Configuration{,Iterator}SafeHandle
carlosmn Jan 15, 2016
ec88896
Get rid of ConflictIteratorSafeHandle and {,Null}IndexSafeHandle
carlosmn Jan 15, 2016
3bc68d5
Get rid of Reflog{,Entry}SafeHandle
carlosmn Jan 15, 2016
b0a88b7
Get rid of some more opaque safe handles
carlosmn Jan 15, 2016
c9c49b1
Use a common abstract class for the handles
carlosmn Jan 15, 2016
5516201
Bump version number to 0.23 (prerelease)
Mar 4, 2016
6a22577
Merge pull request #1271 from ethomson/023_prerelease
carlosmn Mar 7, 2016
3bbf91c
Remove deprecated methods and types
carlosmn Mar 4, 2016
4b8d5ad
Merge branch 'cmn/delete-deprecations'
carlosmn Mar 7, 2016
4bb5f5f
Keep the remote and refspec handle around
carlosmn Dec 14, 2015
53b66be
Bind the missing refspec methods
carlosmn Dec 14, 2015
d6282d3
Properly implement disposable for Remote
carlosmn Dec 15, 2015
24c4a8e
Don't load refspecs eagerly
carlosmn Dec 15, 2015
78a0f4b
Merge branch 'cmn/refspec-transform'
carlosmn Mar 7, 2016
4f68818
Merge commit 'refs/pull/1239/head' of github.com:libgit2/libgit2sharp
carlosmn Mar 7, 2016
4938414
Add the template for changes after v0.22
carlosmn Mar 8, 2016
3c3674a
Mark per-repo config locations obsolete
carlosmn Mar 7, 2016
1bd1cd5
Remove the explicit repository isolation in tests
carlosmn Mar 8, 2016
f67f385
Set the dummy user in the local configuration
carlosmn Mar 8, 2016
917f653
Remove the last uses of explicit config paths for Repository
carlosmn Mar 8, 2016
4924146
Add CHANGES entry for config paths in RepositoryOptions
carlosmn Mar 8, 2016
840422d
Don't load an object just to check its ID
carlosmn Mar 9, 2016
e715299
Merge pull request #1275 from libgit2/cmn/equality-over-id
Mar 9, 2016
06d2866
Make tests aware of the ProgramData config level
carlosmn Mar 9, 2016
ebc43b4
Teach the custom config builder about ProgramData
carlosmn Mar 9, 2016
3615df9
Suppress or fix some unused varible warnings
carlosmn Mar 15, 2016
45846e2
Merge pull request #1274 from libgit2/cmn/obsolete-repo-config-paths
Mar 17, 2016
d45523c
Bring back LeaksContainer
carlosmn Feb 15, 2016
db76f6e
Merge remote-tracking branch 'upstream/master' into pointers
carlosmn Mar 21, 2016
9225134
Dispose of a few Remotes in the tests
carlosmn Mar 21, 2016
395616b
Register Remotes for cleanup with the repo
carlosmn Mar 21, 2016
04fe088
fixup! Merge remote-tracking branch 'upstream/master' into pointers
carlosmn Mar 21, 2016
93e1d46
Do convert unsafe paths into native
carlosmn Mar 21, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
- Windows (x86/amd64): <https://ci.appveyor.com/project/libgit2/libgit2sharp>
- Linux/Mac OS X: <https://travis-ci.org/libgit2/libgit2sharp>

## v0.22 + 1

### Additions

### Changes

- Obsolete the config paths in RepositoryOptions

### Fixes

## v0.22 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.21.1...v0.22))

### Additions
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/AttributesFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AttributesFixture : BaseFixture
[Fact]
public void StagingHonorsTheAttributesFiles()
{
using (var repo = InitIsolatedRepository())
using (var repo = new Repository(InitNewRepository()))
{
CreateAttributesFile(repo);

Expand Down
10 changes: 4 additions & 6 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,10 @@ public void QueryRemoteForRemoteBranch()
[Fact]
public void QueryUnresolvableRemoteForRemoteBranch()
{
var path = SandboxStandardTestRepo();

var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" };

using (var repo = InitIsolatedRepository(path))
var path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
// Update the remote config such that the remote for a
// remote branch cannot be resolved
Expand All @@ -472,12 +471,11 @@ public void QueryUnresolvableRemoteForRemoteBranch()
[Fact]
public void QueryAmbigousRemoteForRemoteBranch()
{
var path = SandboxStandardTestRepo();

const string fetchRefSpec = "+refs/heads/*:refs/remotes/origin/*";
const string url = "http://github.com/libgit2/TestGitRepository";

using (var repo = InitIsolatedRepository(path))
var path = SandboxStandardTestRepo();
using (var repo = new Repository(path))
{
// Add a second remote so that it is ambiguous which remote
// the remote-tracking branch tracks.
Expand Down
17 changes: 0 additions & 17 deletions LibGit2Sharp.Tests/CheckoutFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,23 +1029,6 @@ public void CanCheckoutPathFromCurrentBranch(string fileName)
}
}

[Fact]
public void CanCatchDeprecatedException()
{
bool caught = false;

try
{
throw new CheckoutConflictException();
}
catch (MergeConflictException)
{
caught = true;
}

Assert.True(caught);
}

/// <summary>
/// Helper method to populate a simple repository with
/// a single file and two branches.
Expand Down
5 changes: 2 additions & 3 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,10 @@ public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull()
public void CanCommitWithSignatureFromConfig()
{
string repoPath = InitNewRepository();
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

using (var repo = new Repository(repoPath, options))
using (var repo = new Repository(repoPath))
{
CreateConfigurationWithDummyUser(repo, Constants.Identity);
string dir = repo.Info.Path;
Assert.True(Path.IsPathRooted(dir));
Assert.True(Directory.Exists(dir));
Expand Down
45 changes: 13 additions & 32 deletions LibGit2Sharp.Tests/ConfigurationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ public void CanUnsetAnEntryFromTheLocalConfiguration()
[Fact]
public void CanUnsetAnEntryFromTheGlobalConfiguration()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

var options = BuildFakeConfigs(scd);

string path = SandboxBareTestRepo();
using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global));
Assert.Equal(42, repo.Config.Get<int>("Wow.Man-I-am-totally-global").Value);
Expand Down Expand Up @@ -143,12 +139,10 @@ public void CanReadStringValue()
[Fact]
public void CanEnumerateGlobalConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
CreateConfigurationWithDummyUser(repo, Constants.Identity);
var entry = repo.Config.FirstOrDefault<ConfigurationEntry<string>>(e => e.Key == "user.name");
Assert.NotNull(entry);
Assert.Equal(Constants.Signature.Name, entry.Value);
Expand Down Expand Up @@ -200,16 +194,14 @@ public void CanFindInLocalConfig()
[Fact]
public void CanFindInGlobalConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

var path = SandboxStandardTestRepoGitDir();
using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
var matches = repo.Config.Find(@"\.name", ConfigurationLevel.Global);
var matches = repo.Config.Find("-rocks", ConfigurationLevel.Global);

Assert.NotNull(matches);
Assert.Equal(new[] { "user.name" },
Assert.Equal(new[] { "woot.this-rocks" },
matches.Select(m => m.Key).ToArray());
}
}
Expand Down Expand Up @@ -331,12 +323,8 @@ public void SettingUnsupportedTypeThrows()
[Fact]
public void CanGetAnEntryFromASpecificStore()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

var options = BuildFakeConfigs(scd);

string path = SandboxStandardTestRepo();
using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
Assert.True(repo.Config.HasConfig(ConfigurationLevel.Local));
Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global));
Expand All @@ -356,12 +344,8 @@ public void CanGetAnEntryFromASpecificStore()
[Fact]
public void CanTellIfASpecificStoreContainsAKey()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

var options = BuildFakeConfigs(scd);

string path = SandboxBareTestRepo();
using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
Assert.True(repo.Config.HasConfig(ConfigurationLevel.System));

Expand All @@ -387,16 +371,14 @@ public void CanAccessConfigurationWithoutARepository(Func<string, string> localC
{
var path = SandboxStandardTestRepoGitDir();

string globalConfigPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = globalConfigPath };

using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
repo.Config.Set("my.key", "local");
repo.Config.Set("my.key", "mouse", ConfigurationLevel.Global);
}

using (var config = Configuration.BuildFrom(localConfigurationPathProvider(path), globalConfigPath))
var globalPath = Path.Combine(GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global).Single(), ".gitconfig");
using (var config = Configuration.BuildFrom(localConfigurationPathProvider(path), globalPath))
{
Assert.Equal("local", config.Get<string>("my.key").Value);
Assert.Equal("mouse", config.Get<string>("my.key", ConfigurationLevel.Global).Value);
Expand All @@ -418,11 +400,10 @@ public void PassingANonExistingLocalConfigurationFileToBuildFromthrowss()
public void CannotBuildAProperSignatureFromConfigWhenFullIdentityCannotBeFoundInTheConfig(string name, string email)
{
string repoPath = InitNewRepository();
string configPath = CreateConfigurationWithDummyUser(name, email);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

using (var repo = new Repository(repoPath, options))
using (var repo = new Repository(repoPath))
{
CreateConfigurationWithDummyUser(repo, name, email);
Assert.Equal(name, repo.Config.GetValueOrDefault<string>("user.name"));
Assert.Equal(email, repo.Config.GetValueOrDefault<string>("user.email"));

Expand Down
31 changes: 6 additions & 25 deletions LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,9 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
repo.Config.Unset("core.filemode");
}

SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

var options = BuildFakeSystemConfigFilemodeOption(scd, true);

using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
SetFilemode(repo, true);
var changes = repo.Diff.Compare<TreeChanges>(new[] { file });

Assert.Equal(1, changes.Count());
Expand All @@ -1059,34 +1056,18 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
Assert.Equal(Mode.NonExecutableFile, change.Mode);
}

options = BuildFakeSystemConfigFilemodeOption(scd, false);

using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
SetFilemode(repo, false);
var changes = repo.Diff.Compare<TreeChanges>(new[] { file });

Assert.Equal(0, changes.Count());
}
}

private RepositoryOptions BuildFakeSystemConfigFilemodeOption(
SelfCleaningDirectory scd,
bool value)
void SetFilemode(Repository repo, bool value)
{
Directory.CreateDirectory(scd.DirectoryPath);

var options = new RepositoryOptions
{
SystemConfigurationLocation = Path.Combine(
scd.RootedDirectoryPath, "fake-system.config")
};

StringBuilder sb = new StringBuilder()
.AppendFormat("[core]{0}", Environment.NewLine)
.AppendFormat("filemode = {1}{0}", Environment.NewLine, value);
Touch("", options.SystemConfigurationLocation, sb.ToString());

return options;
repo.Config.Set("core.filemode", value);
}

[Fact]
Expand Down
31 changes: 6 additions & 25 deletions LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
repo.Config.Unset("core.filemode", ConfigurationLevel.Local);
}

SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

var options = BuildFakeSystemConfigFilemodeOption(scd, true);

using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
SetFilemode(repo, true);
var changes = repo.Diff.Compare<TreeChanges>(new[] { file });

Assert.Equal(1, changes.Count());
Expand All @@ -142,34 +139,18 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
Assert.Equal(Mode.NonExecutableFile, change.Mode);
}

options = BuildFakeSystemConfigFilemodeOption(scd, false);

using (var repo = new Repository(path, options))
using (var repo = new Repository(path))
{
SetFilemode(repo, false);
var changes = repo.Diff.Compare<TreeChanges>(new[] { file });

Assert.Equal(0, changes.Count());
}
}

private RepositoryOptions BuildFakeSystemConfigFilemodeOption(
SelfCleaningDirectory scd,
bool value)
void SetFilemode(Repository repo, bool value)
{
Directory.CreateDirectory(scd.DirectoryPath);

var options = new RepositoryOptions
{
SystemConfigurationLocation = Path.Combine(
scd.RootedDirectoryPath, "fake-system.config")
};

StringBuilder sb = new StringBuilder()
.AppendFormat("[core]{0}", Environment.NewLine)
.AppendFormat("filemode = {1}{0}", Environment.NewLine, value);
File.WriteAllText(options.SystemConfigurationLocation, sb.ToString());

return options;
repo.Config.Set("core.filemode", value);
}

[Fact]
Expand Down
4 changes: 1 addition & 3 deletions LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()

string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);

var options = BuildFakeConfigs(BuildSelfCleaningDirectory());

using (var clonedRepo = new Repository(clonedRepoPath, options))
using (var clonedRepo = new Repository(clonedRepoPath))
{
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));

Expand Down
11 changes: 4 additions & 7 deletions LibGit2Sharp.Tests/FilterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,9 @@ public void CanFilterLargeFiles()
string attributesPath = Path.Combine(Directory.GetParent(repoPath).Parent.FullName, ".gitattributes");
FileInfo attributesFile = new FileInfo(attributesPath);

string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };

using (Repository repo = new Repository(repoPath, repositoryOptions))
using (Repository repo = new Repository(repoPath))
{
CreateConfigurationWithDummyUser(repo, Constants.Identity);
File.WriteAllText(attributesPath, "*.blob filter=test");
repo.Stage(attributesFile.Name);
repo.Stage(contentFile.Name);
Expand Down Expand Up @@ -421,9 +419,8 @@ private static FileInfo StageNewFile(IRepository repo, string contents = "null")

private Repository CreateTestRepository(string path)
{
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
var repository = new Repository(path, repositoryOptions);
var repository = new Repository(path);
CreateConfigurationWithDummyUser(repository, Constants.Identity);
CreateAttributesFile(repository, "* filter=test");
return repository;
}
Expand Down
Loading