public string GetRepositoryPath(string path) { ThrowIfDisposed(); var buf = new git_buf(); _trace.WriteLine($"Discovering repository from path '{path}'..."); int error = git_repository_discover(buf, path, true, null); try { switch (error) { case GIT_OK: string repoPath = buf.ToString(); _trace.WriteLine($"Found repository at '{repoPath}'."); return(repoPath); case GIT_ENOTFOUND: return(null); default: ThrowIfError(error, nameof(git_repository_discover)); return(null); } } finally { git_buf_dispose(buf); } }
public string GetRepositoryPath(string path) { var buf = new git_buf(); int error = git_repository_discover(buf, path, true, null); try { switch (error) { case GIT_OK: return(buf.ToString()); case GIT_ENOTFOUND: return(null); default: ThrowIfError(error, nameof(git_repository_discover)); return(null); } } finally { git_buf_dispose(buf); } }
public unsafe static string GetSearchPath(ConfigurationLevel level) { GitBuffer buf = new GitBuffer(); git_buf nativeBuffer = buf.NativeBuffer; Ensure.NativeSuccess(libgit2.git_libgit2_opts(git_libgit2_opt_t.GIT_OPT_GET_SEARCH_PATH, (git_config_level_t)level, nativeBuffer)); fixed(byte *bp = buf.Content) { return(Utf8Converter.FromNative(bp)); } }
public unsafe GitBuffer GetFilteredContent(string path, BlobFilterOptions options) { Ensure.ArgumentNotNull(path, "path"); Ensure.ArgumentNotNull(options, "options"); GitBuffer buf = new GitBuffer(); git_buf nativeBuffer = buf.NativeBuffer; Ensure.NativeSuccess(() => { git_blob_filter_options nativeOptions = options.ToNative(); return(libgit2.git_blob_filter(nativeBuffer, NativeBlob, path, &nativeOptions)); }, this); return(buf); }