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:
-rw-r--r--LibGit2Sharp.Tests/RepositoryFixture.cs9
-rw-r--r--LibGit2Sharp/Repository.cs12
2 files changed, 21 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs
index 68d3318a..277f32b8 100644
--- a/LibGit2Sharp.Tests/RepositoryFixture.cs
+++ b/LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -46,11 +46,20 @@ namespace LibGit2Sharp.Tests
repo.Info.Path.ShouldEqual(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar));
repo.Info.IsBare.ShouldBeFalse();
+ AssertIsHidden(repo.Info.Path);
+
AssertInitializedRepository(repo);
}
}
}
+ private static void AssertIsHidden(string repoPath)
+ {
+ var attribs = File.GetAttributes(repoPath);
+
+ (attribs & FileAttributes.Hidden).ShouldEqual(FileAttributes.Hidden);
+ }
+
[Test]
public void CreatingRepoWithBadParamsThrows()
{
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 156ed419..25cf1d53 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Text;
using LibGit2Sharp.Core;
@@ -178,9 +179,20 @@ namespace LibGit2Sharp
string normalizedPath = NativeMethods.git_repository_path(repo, GitRepositoryPathId.GIT_REPO_PATH).MarshallAsString();
repo.Dispose();
+ if (!isBare)
+ {
+ HideGitFolder(normalizedPath);
+ }
+
return PosixPathHelper.ToNative(normalizedPath);
}
+ private static void HideGitFolder(string gitDirPath)
+ {
+ //TODO: Push this down into libgit2
+ File.SetAttributes(gitDirPath, File.GetAttributes(gitDirPath) | FileAttributes.Hidden);
+ }
+
/// <summary>
/// Try to lookup an object by its <see cref = "ObjectId" /> and <see cref = "GitObjectType" />. If no matching object is found, null will be returned.
/// </summary>