]> git.proxmox.com Git - libgit2.git/blob - src/refspec.h
remote: create FETCH_HEAD with a refspecless remote
[libgit2.git] / src / refspec.h
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 #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 char *string;
15 char *src;
16 char *dst;
17 unsigned int force :1,
18 push : 1,
19 pattern :1,
20 dwim :1,
21 matching :1;
22 };
23
24 #define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*"
25
26 int git_refspec_parse(struct git_refspec *refspec, const char *str);
27 int git_refspec__parse(
28 struct git_refspec *refspec,
29 const char *str,
30 bool is_fetch);
31
32 void git_refspec__free(git_refspec *refspec);
33
34 /**
35 * Transform a reference to its target following the refspec's rules,
36 * and writes the results into a git_buf.
37 *
38 * @param out where to store the target name
39 * @param spec the refspec
40 * @param name the name of the reference to transform
41 * @return 0 or error if buffer allocation fails
42 */
43 int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name);
44
45 /**
46 * Transform a reference from its target following the refspec's rules,
47 * and writes the results into a git_buf.
48 *
49 * @param out where to store the source name
50 * @param spec the refspec
51 * @param name the name of the reference to transform
52 * @return 0 or error if buffer allocation fails
53 */
54 int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *name);
55
56 int git_refspec__serialize(git_buf *out, const git_refspec *refspec);
57
58 /**
59 * Determines if a refspec is a wildcard refspec.
60 *
61 * @param spec the refspec
62 * @return 1 if the refspec is a wildcard, 0 otherwise
63 */
64 int git_refspec_is_wildcard(const git_refspec *spec);
65
66 #endif