Exemplo n.º 1
0
Arquivo: gitg-ref.c Projeto: krh/gitg
GitgRef *
gitg_ref_new(gchar const *hash, gchar const *name)
{
	GitgRef *inst = g_new0(GitgRef, 1);

	gitg_utils_sha1_to_hash(hash, inst->hash);
	inst->name = g_strdup(name);
	
	PrefixTypeMap map[] = {
		{"refs/heads/", GITG_REF_TYPE_BRANCH},
		{"refs/remotes/", GITG_REF_TYPE_REMOTE},
		{"refs/tags/", GITG_REF_TYPE_TAG}
	};
	
	// set type from name
	int i;
	for (i = 0; i < sizeof(map) / sizeof(PrefixTypeMap); ++i)
	{
		if (!g_str_has_prefix(name, map[i].prefix))
			continue;
		
		inst->type = map[i].type;
		inst->shortname = g_strdup(name + strlen(map[i].prefix));
		break;
	}
	
	if (inst->shortname == NULL)
	{
		inst->type = GITG_REF_TYPE_NONE;
		inst->shortname = g_strdup(name);
	}
	
	return inst;
}
Exemplo n.º 2
0
Arquivo: gitg-utils.c Projeto: hb/gitg
gchar *
gitg_utils_sha1_to_hash_new(gchar const *sha1)
{
    gchar *ret = g_new(gchar, HASH_BINARY_SIZE);
    gitg_utils_sha1_to_hash(sha1, ret);

    return ret;
}
Exemplo n.º 3
0
gchar *
gitg_utils_sha1_to_hash_new(gchar const *sha1)
{
	gchar *ret = g_new(gchar, 20);
	gitg_utils_sha1_to_hash(sha1, ret);
	
	return ret;
}