예제 #1
0
파일: refspec.c 프로젝트: AChep/libgit2
int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name)
{
	assert(out && spec && name);
	git_buf_sanitize(out);

	if (!git_refspec_dst_matches(spec, name)) {
		giterr_set(GITERR_INVALID, "ref '%s' doesn't match the destination", name);
		return -1;
	}

	if (!spec->pattern)
		return git_buf_puts(out, spec->src);

	return refspec_transform(out, spec->dst, spec->src, name);
}
예제 #2
0
PyObject *
Refspec_dst_matches(Refspec *self, PyObject *py_str)
{
    char *str;
    int res;

    str = py_str_to_c_str(py_str, NULL);
    if (!str)
        return NULL;

    res = git_refspec_dst_matches(self->refspec, str);
    free(str);

    if (res)
        Py_RETURN_TRUE;

    Py_RETURN_FALSE;
}