refspec.h 1.11 KB
Newer Older
Vicent Marti committed
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
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
#ifndef INCLUDE_refspec_h__
#define INCLUDE_refspec_h__

10 11
#include "common.h"

Carlos Martín Nieto committed
12
#include "git2/refspec.h"
13
#include "buffer.h"
14
#include "vector.h"
Carlos Martín Nieto committed
15 16

struct git_refspec {
17
	char *string;
Carlos Martín Nieto committed
18 19
	char *src;
	char *dst;
20
	unsigned int force :1,
21
		push : 1,
22 23
		pattern :1,
		matching :1;
Carlos Martín Nieto committed
24 25
};

26 27
#define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*"

28 29 30 31
int git_refspec__parse(
	struct git_refspec *refspec,
	const char *str,
	bool is_fetch);
Carlos Martín Nieto committed
32

33 34
void git_refspec__free(git_refspec *refspec);

35 36
int git_refspec__serialize(git_buf *out, const git_refspec *refspec);

37 38 39 40 41 42 43 44
/**
 * 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);

45 46 47 48 49 50
/**
 * DWIM `spec` with `refs` existing on the remote, append the dwim'ed
 * result in `out`.
 */
int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs);

Carlos Martín Nieto committed
51
#endif