]> git.proxmox.com Git - libgit2.git/blob - src/refspec.h
Move `url` to last place in parameter list
[libgit2.git] / src / refspec.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
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 #ifndef INCLUDE_refspec_h__
8 #define INCLUDE_refspec_h__
9
10 #include "git2/refspec.h"
11 #include "buffer.h"
12
13 struct git_refspec {
14 struct git_refspec *next;
15 char *src;
16 char *dst;
17 unsigned int force :1,
18 pattern :1,
19 matching :1;
20 };
21
22 #define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*"
23
24 int git_refspec_parse(struct git_refspec *refspec, const char *str);
25 int git_refspec__parse(
26 struct git_refspec *refspec,
27 const char *str,
28 bool is_fetch);
29
30 void git_refspec__free(git_refspec *refspec);
31
32 /**
33 * Transform a reference to its target following the refspec's rules,
34 * and writes the results into a git_buf.
35 *
36 * @param out where to store the target name
37 * @param spec the refspec
38 * @param name the name of the reference to transform
39 * @return 0 or error if buffer allocation fails
40 */
41 int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name);
42
43 /**
44 * Transform a reference from its target following the refspec's rules,
45 * and writes the results into a git_buf.
46 *
47 * @param out where to store the source name
48 * @param spec the refspec
49 * @param name the name of the reference to transform
50 * @return 0 or error if buffer allocation fails
51 */
52 int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *name);
53
54 int git_refspec__serialize(git_buf *out, const git_refspec *refspec);
55
56 /**
57 * Determines if a refspec is a wildcard refspec.
58 *
59 * @param spec the refspec
60 * @return 1 if the refspec is a wildcard, 0 otherwise
61 */
62 int git_refspec_is_wildcard(const git_refspec *spec);
63
64 #endif