|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the swift-libgit2 open source project. |
| 4 | +// |
| 5 | +// Copyright (c) Margins Technologies LLC. |
| 6 | +// Licensed under the Apache License, Version 2.0. |
| 7 | +// |
| 8 | +//===----------------------------------------------------------------------===// |
| 9 | + |
| 10 | +import CLibgit2 |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +/// Initializes the given `git_refdb_backend` instance. |
| 15 | +/// - Parameters: |
| 16 | +/// - opts: The `git_refdb_backend` instance to initialize. |
| 17 | +/// - version: The version to use. Pass ``gitRefDBBackendVersion``. |
| 18 | +/// - Returns: A ``GitErrorCode`` instance. |
| 19 | +/// |
| 20 | +/// ## C Equivalent |
| 21 | +/// |
| 22 | +/// [`git_refdb_init_backend()`](https://libgit2.org/docs/reference/main/sys/refdb_backend/git_refdb_init_backend.html) |
| 23 | +public func gitRefDBInitBackend( |
| 24 | + opts : UnsafeMutablePointer<git_refdb_backend>, |
| 25 | + version : UInt32 |
| 26 | +) -> GitErrorCode |
| 27 | +{ |
| 28 | + return withCConversion |
| 29 | + { |
| 30 | + return git_refdb_init_backend( |
| 31 | + opts, |
| 32 | + version |
| 33 | + ) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +/// Creates a default reference database backend, based on the file system. |
| 40 | +/// - Parameters: |
| 41 | +/// - backendOut: The pointer in which to store the reference database |
| 42 | +/// backend. |
| 43 | +/// - repo: The repository to use. The underlying type must be |
| 44 | +/// `git_repository`. |
| 45 | +/// - Returns: A ``GitErrorCode`` instance. |
| 46 | +/// |
| 47 | +/// ## Discussion |
| 48 | +/// |
| 49 | +/// This function is normally called automatically when a repository is |
| 50 | +/// created or opened. It may be called manually to explicitly create a file |
| 51 | +/// system-based reference database backend for a repository. |
| 52 | +/// |
| 53 | +/// ## C Equivalent |
| 54 | +/// |
| 55 | +/// [`git_refdb_backend_fs()`](https://libgit2.org/docs/reference/main/sys/refdb_backend/git_refdb_backend_fs.html) |
| 56 | +public func gitRefDBBackendFS( |
| 57 | + backendOut : UnsafeMutablePointer<UnsafeMutablePointer<git_refdb_backend>?>, |
| 58 | + repo : OpaquePointer |
| 59 | +) -> GitErrorCode |
| 60 | +{ |
| 61 | + return withCConversion |
| 62 | + { |
| 63 | + return git_refdb_backend_fs( |
| 64 | + backendOut, |
| 65 | + repo |
| 66 | + ) |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +/// Sets the given reference database backend as the custom backend of the |
| 73 | +/// given reference database. |
| 74 | +/// - Parameters: |
| 75 | +/// - refDB: The reference database to update. The underlying type must be |
| 76 | +/// `git_refdb`. |
| 77 | +/// - backend: The reference database backend to use. |
| 78 | +/// - Returns: A ``GitErrorCode`` instance. |
| 79 | +/// |
| 80 | +/// ## Discussion |
| 81 | +/// |
| 82 | +/// - Important: If the operation succeeds, ownership of the given reference |
| 83 | +/// database backend will be transferred to the given reference database. The |
| 84 | +/// caller must not free the reference database backend. |
| 85 | +/// |
| 86 | +/// ## C Equivalent |
| 87 | +/// |
| 88 | +/// [`git_refdb_set_backend()`](https://libgit2.org/docs/reference/main/sys/refdb_backend/git_refdb_set_backend.html) |
| 89 | +public func gitRefDBSetBackend( |
| 90 | + refDB : OpaquePointer, |
| 91 | + backend : UnsafeMutablePointer<git_refdb_backend> |
| 92 | +) -> GitErrorCode |
| 93 | +{ |
| 94 | + return withCConversion |
| 95 | + { |
| 96 | + return git_refdb_set_backend( |
| 97 | + refDB, |
| 98 | + backend |
| 99 | + ) |
| 100 | + } |
| 101 | +} |
0 commit comments