refspec.h 1.7 KB
Newer Older
Vicent Marti committed
1
/*
schu committed
2
 * Copyright (C) 2009-2012 the libgit2 contributors
Vicent Marti committed
3 4 5 6
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
Carlos Martín Nieto committed
7 8 9 10
#ifndef INCLUDE_refspec_h__
#define INCLUDE_refspec_h__

#include "git2/refspec.h"
11
#include "buffer.h"
Carlos Martín Nieto committed
12 13

struct git_refspec {
14
	struct git_refspec *next;
Carlos Martín Nieto committed
15 16
	char *src;
	char *dst;
17 18 19
	unsigned int force :1,
		pattern :1,
		matching :1;
Carlos Martín Nieto committed
20 21
};

22 23
#define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*"

Carlos Martín Nieto committed
24
int git_refspec_parse(struct git_refspec *refspec, const char *str);
25 26 27 28
int git_refspec__parse(
	struct git_refspec *refspec,
	const char *str,
	bool is_fetch);
Carlos Martín Nieto committed
29

30 31
void git_refspec__free(git_refspec *refspec);

32 33 34 35 36 37 38
/**
 * Transform a reference to its target following the refspec's rules,
 * and writes the results into a git_buf.
 *
 * @param out where to store the target name
 * @param spec the refspec
 * @param name the name of the reference to transform
39
 * @return 0 or error if buffer allocation fails
40 41 42
 */
int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name);

43 44 45 46 47 48 49 50 51 52 53
/**
 * Transform a reference from its target following the refspec's rules,
 * and writes the results into a git_buf.
 *
 * @param out where to store the source name
 * @param spec the refspec
 * @param name the name of the reference to transform
 * @return 0 or error if buffer allocation fails
 */
int git_refspec_transform_l(git_buf *out, const git_refspec *spec, const char *name);

54 55
int git_refspec__serialize(git_buf *out, const git_refspec *refspec);

56 57 58 59 60 61 62 63
/**
 * Determines if a refspec is a wildcard refspec.
 *
 * @param spec the refspec
 * @return 1 if the refspec is a wildcard, 0 otherwise
 */
int git_refspec_is_wildcard(const git_refspec *spec);

Carlos Martín Nieto committed
64
#endif