Beispiel #1
0
static int filter_ref__cb(git_remote_head *head, void *payload)
{
	struct filter_payload *p = payload;
	int match = 0;

	if (!git_reference_is_valid_name(head->name))
		return 0;

	if (!p->found_head && strcmp(head->name, GIT_HEAD_FILE) == 0)
		p->found_head = 1;
	else if (git_refspec_src_matches(p->spec, head->name))
			match = 1;
	else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL &&
		 git_refspec_src_matches(p->tagspec, head->name))
			match = 1;

	if (!match)
		return 0;

	/* If we have the object, mark it so we don't ask for it */
	if (git_odb_exists(p->odb, &head->oid))
		head->local = 1;
	else
		p->remote->need_pack = 1;

	return git_vector_insert(&p->remote->refs, head);
}
Beispiel #2
0
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec)
{
	int match = 0;

	if (!git_reference_is_valid_name(head->name))
		return 0;

	if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
		/*
		 * If tagopt is --tags, always request tags
		 * in addition to the remote's refspecs
		 */
		if (git_refspec_src_matches(tagspec, head->name))
			match = 1;
	}

	if (!match && git_remote__matching_refspec(remote, head->name))
		match = 1;

	if (!match)
		return 0;

	/* If we have the object, mark it so we don't ask for it */
	if (git_odb_exists(odb, &head->oid)) {
		head->local = 1;
	}
	else
		remote->need_pack = 1;

	return git_vector_insert(&remote->refs, head);
}
Beispiel #3
0
int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name)
{
	assert(out && spec && name);
	git_buf_sanitize(out);

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

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

	return refspec_transform(out, spec->src, spec->dst, name);
}
Beispiel #4
0
PyObject *
Refspec_src_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_src_matches(self->refspec, str);
    free(str);

    if (res)
        Py_RETURN_TRUE;

    Py_RETURN_FALSE;
}
Beispiel #5
0
void test_network_remotes__fnmatch(void)
{
	cl_assert(git_refspec_src_matches(_refspec, "refs/heads/master"));
	cl_assert(git_refspec_src_matches(_refspec, "refs/heads/multi/level/branch"));
}