1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 /**
8  * License: GPL-2.0(Linking Exception)
9  */
10 module libgit2.refspec;
11 
12 
13 private static import libgit2.buffer;
14 private static import libgit2.net;
15 private static import libgit2.types;
16 private import libgit2.common: GIT_EXTERN;
17 
18 /*
19  * @file git2/refspec.h
20  * @brief Git refspec attributes
21  * @defgroup git_refspec Git refspec attributes
22  * @ingroup Git
23  * @{
24  */
25 extern (C):
26 nothrow @nogc:
27 public:
28 
29 /**
30  * Parse a given refspec string
31  *
32  * Params:
33  *      refspec = a pointer to hold the refspec handle
34  *      input = the refspec string
35  *      is_fetch = is this a refspec for a fetch
36  *
37  * Returns: 0 if the refspec string could be parsed, -1 otherwise
38  */
39 @GIT_EXTERN
40 int git_refspec_parse(libgit2.types.git_refspec** refspec, const (char)* input, int is_fetch);
41 
42 /**
43  * Free a refspec object which has been created by git_refspec_parse
44  *
45  * Params:
46  *      refspec = the refspec object
47  */
48 @GIT_EXTERN
49 void git_refspec_free(libgit2.types.git_refspec* refspec);
50 
51 /**
52  * Get the source specifier
53  *
54  * Params:
55  *      refspec = the refspec
56  *
57  * Returns: the refspec's source specifier
58  */
59 @GIT_EXTERN
60 const (char)* git_refspec_src(const (libgit2.types.git_refspec)* refspec);
61 
62 /**
63  * Get the destination specifier
64  *
65  * Params:
66  *      refspec = the refspec
67  *
68  * Returns: the refspec's destination specifier
69  */
70 @GIT_EXTERN
71 const (char)* git_refspec_dst(const (libgit2.types.git_refspec)* refspec);
72 
73 /**
74  * Get the refspec's string
75  *
76  * Params:
77  *      refspec = the refspec
78  *
79  * Returns: s the refspec's original string
80  */
81 @GIT_EXTERN
82 const (char)* git_refspec_string(const (libgit2.types.git_refspec)* refspec);
83 
84 /**
85  * Get the force update setting
86  *
87  * Params:
88  *      refspec = the refspec
89  *
90  * Returns: 1 if force update has been set, 0 otherwise
91  */
92 @GIT_EXTERN
93 int git_refspec_force(const (libgit2.types.git_refspec)* refspec);
94 
95 /**
96  * Get the refspec's direction.
97  *
98  * Params:
99  *      spec = refspec
100  *
101  * Returns: git_direction.GIT_DIRECTION_FETCH or git_direction.GIT_DIRECTION_PUSH
102  */
103 @GIT_EXTERN
104 libgit2.net.git_direction git_refspec_direction(const (libgit2.types.git_refspec)* spec);
105 
106 /**
107  * Check if a refspec's source descriptor matches a reference
108  *
109  * Params:
110  *      refspec = the refspec
111  *      refname = the name of the reference to check
112  *
113  * Returns: 1 if the refspec matches, 0 otherwise
114  */
115 @GIT_EXTERN
116 int git_refspec_src_matches(const (libgit2.types.git_refspec)* refspec, const (char)* refname);
117 
118 /**
119  * Check if a refspec's destination descriptor matches a reference
120  *
121  * Params:
122  *      refspec = the refspec
123  *      refname = the name of the reference to check
124  *
125  * Returns: 1 if the refspec matches, 0 otherwise
126  */
127 @GIT_EXTERN
128 int git_refspec_dst_matches(const (libgit2.types.git_refspec)* refspec, const (char)* refname);
129 
130 /**
131  * Transform a reference to its target following the refspec's rules
132  *
133  * Params:
134  *      out_ = where to store the target name
135  *      spec = the refspec
136  *      name = the name of the reference to transform
137  *
138  * Returns: 0, git_error_code.GIT_EBUFS or another error
139  */
140 @GIT_EXTERN
141 int git_refspec_transform(libgit2.buffer.git_buf* out_, const (libgit2.types.git_refspec)* spec, const (char)* name);
142 
143 /**
144  * Transform a target reference to its source reference following the refspec's
145  * rules
146  *
147  * Params:
148  *      out_ = where to store the source reference name
149  *      spec = the refspec
150  *      name = the name of the reference to transform
151  *
152  * Returns: 0, git_error_code.GIT_EBUFS or another error
153  */
154 @GIT_EXTERN
155 int git_refspec_rtransform(libgit2.buffer.git_buf* out_, const (libgit2.types.git_refspec)* spec, const (char)* name);