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