repo: Update HEAD after a commit

This commit is contained in:
Colin Walters 2011-10-14 22:56:40 -04:00
parent 9cac933c7f
commit 72c7385295

View File

@ -193,6 +193,10 @@ parse_checksum_file (HacktreeRepo *self,
goto out;
}
}
else
{
g_strchomp (ret_sha256);
}
*sha256 = ret_sha256;
ret = TRUE;
@ -200,6 +204,25 @@ parse_checksum_file (HacktreeRepo *self,
return ret;
}
static gboolean
write_checksum_file (const char *path,
const char *sha256,
GError **error)
{
gboolean ret = FALSE;
char *buf = NULL;
buf = g_strconcat (sha256, "\n", NULL);
if (!g_file_set_contents (path, buf, -1, error))
goto out;
ret = TRUE;
out:
g_free (buf);
return ret;
}
gboolean
hacktree_repo_check (HacktreeRepo *self, GError **error)
{
@ -1207,6 +1230,12 @@ hacktree_repo_commit (HacktreeRepo *self,
commit, &ret_commit_checksum, error))
goto out;
if (!write_checksum_file (priv->head_ref_path, g_checksum_get_string (ret_commit_checksum), error))
goto out;
g_free (priv->current_head);
priv->current_head = g_strdup (g_checksum_get_string (ret_commit_checksum));
ret = TRUE;
out:
if (!ret)