1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 13:06:15 +02:00

eeshow/git-file.c (vcs_git_init): common initialization

This commit is contained in:
Werner Almesberger 2016-08-04 19:40:29 -03:00
parent 1c6116a8d6
commit 17360f7ddd
3 changed files with 15 additions and 4 deletions

View File

@ -421,16 +421,23 @@ static bool try_related(struct vcs_git *vcs_git)
}
struct vcs_git *vcs_git_open(const char *revision, const char *name,
const struct vcs_git *related)
void vcs_git_init(void)
{
static bool initialized = 0;
struct vcs_git *vcs_git = alloc_type(struct vcs_git);
if (!initialized) {
git_libgit2_init();
initialized = 1;
}
}
struct vcs_git *vcs_git_open(const char *revision, const char *name,
const struct vcs_git *related)
{
struct vcs_git *vcs_git = alloc_type(struct vcs_git);
vcs_git_init();
vcs_git->name = stralloc(name);
vcs_git->revision = revision ? stralloc(revision) : NULL;

View File

@ -29,6 +29,8 @@
struct vcs_git;
struct file;
void vcs_git_init(void);
struct vcs_git *vcs_git_open(const char *revision, const char *name,
const struct vcs_git *related);
void vcs_git_read(void *ctx, struct file *file,

View File

@ -17,6 +17,7 @@
#include "util.h"
#include "main.h"
#include "git-file.h"
#include "git-hist.h"
@ -134,7 +135,8 @@ struct hist *vcs_git_hist(const char *path)
head = new_commit(0);
git_libgit2_init(); /* @@@ */
vcs_git_init();
if (git_repository_open_ext(&repo, path,
GIT_REPOSITORY_OPEN_CROSS_FS, NULL)) {
e = giterr_last();