Skip to content

Commit 0a14eda

Browse files
Add Refs (Advanced) bindings
1 parent 54b872c commit 0a14eda

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
/// Creates a new direct reference using the given name and ID.
15+
/// - Parameters:
16+
/// - name: The reference name to use.
17+
/// - oid: The reference ID to use.
18+
/// - peel: The ID of the first non-tag object to use.
19+
/// - Returns: The new direct reference using the given name and ID.
20+
///
21+
/// ## C Equivalent
22+
///
23+
/// [`git_reference__alloc()`](https://libgit2.org/docs/reference/main/sys/refs/git_reference__alloc.html)
24+
public func gitReferenceAlloc(
25+
name : String,
26+
oid : GitOID,
27+
peel : GitOID?
28+
) -> OpaquePointer?
29+
{
30+
return try? oid.withCValue
31+
{
32+
cOID in
33+
34+
return try peel.withOptionalCValue
35+
{
36+
cPeel in
37+
38+
return git_reference__alloc(
39+
name,
40+
cOID,
41+
cPeel
42+
)
43+
}
44+
}
45+
}
46+
47+
48+
49+
/// Creates a new symbolic reference using the given name and target.
50+
/// - Parameters:
51+
/// - name: The reference name to use.
52+
/// - target: The reference target to use.
53+
/// - Returns: The new direct reference using the given name and target.
54+
///
55+
/// ## C Equivalent
56+
///
57+
/// [`git_reference__alloc_symbolic()`](https://libgit2.org/docs/reference/main/sys/refs/git_reference__alloc_symbolic.html)
58+
public func gitReferenceAllocSymbolic(
59+
name : String,
60+
target : String
61+
) -> OpaquePointer?
62+
{
63+
return git_reference__alloc_symbolic(
64+
name,
65+
target
66+
)
67+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Refs (Advanced)
2+
3+
Low-level reference creation.
4+
5+
## Topics
6+
7+
### Functions
8+
9+
- ``gitReferenceAlloc(name:oid:peel:)``
10+
- ``gitReferenceAllocSymbolic(name:target:)``

0 commit comments

Comments
 (0)