summaryrefslogtreecommitdiff
path: root/builtin/init-db.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 587a5055ed..d6cdee8a39 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -7,6 +7,7 @@
#include "builtin.h"
#include "exec_cmd.h"
#include "parse-options.h"
+#include "refs.h"
#ifndef DEFAULT_GIT_TEMPLATE_DIR
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
@@ -187,6 +188,7 @@ static int create_default_files(const char *template_path)
char junk[2];
int reinit;
int filemode;
+ struct strbuf err = STRBUF_INIT;
if (len > sizeof(path)-50)
die(_("insane git directory %s"), git_dir);
@@ -236,8 +238,10 @@ static int create_default_files(const char *template_path)
strcpy(path + len, "HEAD");
reinit = (!access(path, R_OK)
|| readlink(path, junk, sizeof(junk)-1) != -1);
- if (!reinit) {
- if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
+ if (!reinit &&
+ create_symref("HEAD", "refs/heads/master", NULL, &err)) {
+ error("%s", err.buf);
+ strbuf_release(&err);
exit(1);
}