From 17360f7ddd5992220843acfdd7ef5d18558f1c3e Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 4 Aug 2016 19:40:29 -0300 Subject: [PATCH] eeshow/git-file.c (vcs_git_init): common initialization --- eeshow/git-file.c | 13 ++++++++++--- eeshow/git-file.h | 2 ++ eeshow/git-hist.c | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/eeshow/git-file.c b/eeshow/git-file.c index 1aaea6a..7dc75a5 100644 --- a/eeshow/git-file.c +++ b/eeshow/git-file.c @@ -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; diff --git a/eeshow/git-file.h b/eeshow/git-file.h index 1b4c0ff..7d1b637 100644 --- a/eeshow/git-file.h +++ b/eeshow/git-file.h @@ -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, diff --git a/eeshow/git-hist.c b/eeshow/git-hist.c index b4b48a6..bf0129d 100644 --- a/eeshow/git-hist.c +++ b/eeshow/git-hist.c @@ -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();