diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2008-03-24 16:14:52 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-03-25 00:34:05 -0700 |
commit | 5cc8f372509298d13632d8784bc851a587937550 (patch) | |
tree | f05904feb2d9ee3e5f277b77d731644c765a85cf /builtin-init-db.c | |
parent | 76ce946294bd17f350c7c0a3927d8986b73ed480 (diff) | |
download | git-5cc8f372509298d13632d8784bc851a587937550.tar.gz git-5cc8f372509298d13632d8784bc851a587937550.tar.xz |
init: show "Reinit" message even in an (existing) empty repository
Earlier, git-init tested for a valid HEAD ref, but if the repository
was empty, there was none. Instead, test for the existence of
the file $GIT_DIR/HEAD.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-init-db.c')
-rw-r--r-- | builtin-init-db.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin-init-db.c b/builtin-init-db.c index 79eaf8d6e..2854868b4 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -167,9 +167,9 @@ static int create_default_files(const char *git_dir, const char *template_path) { unsigned len = strlen(git_dir); static char path[PATH_MAX]; - unsigned char sha1[20]; struct stat st1; char repo_version_string[10]; + char junk[2]; int reinit; int filemode; @@ -219,7 +219,8 @@ static int create_default_files(const char *git_dir, const char *template_path) * branch, if it does not exist yet. */ strcpy(path + len, "HEAD"); - reinit = !read_ref("HEAD", sha1); + reinit = (!access(path, R_OK) + || readlink(path, junk, sizeof(junk)-1) != -1); if (!reinit) { if (create_symref("HEAD", "refs/heads/master", NULL) < 0) exit(1); |