summaryrefslogtreecommitdiff
path: root/git-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'git-util.c')
-rw-r--r--git-util.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/git-util.c b/git-util.c
new file mode 100644
index 0000000..71cf6cd
--- /dev/null
+++ b/git-util.c
@@ -0,0 +1,35 @@
+/*
+ * git-util.c - Git utility functions
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <stdbool.h>
+
+#include <git2.h>
+
+#include "git-util.h"
+
+
+/*
+ * Git documentation says that git_libgit2_init can be called more then once
+ * but doesn't quite what happens then, e.g., whether references obtained
+ * before an init (except for the first, of course) can still be used after
+ * it. So we play it safe and initialize only once.
+ */
+
+void git_init_once(void)
+{
+ static bool initialized = 0;
+
+ if (!initialized) {
+ git_libgit2_init();
+ initialized = 1;
+ }
+}