[PATCH] init: show "Reinit" message even in an (existing) empty repository
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 24, 2008, 15:14 UTC
- Message-ID
- <alpine.LSU.1.00.0803241613480.4353@racer.site>
- In-Reply-To
- <alpine.LSU.1.00.0803241611200.4353@racer.site>
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> ---
I realised this while testing the core.initHook patch.
builtin-init-db.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c index 1975910..ceb4727 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -168,10 +168,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]; int reinit; int filemode; if (len > sizeof(path)-50) @@ -220,7 +219,7 @@ 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); if (!reinit) { if (create_symref("HEAD", "refs/heads/master", NULL) < 0) exit(1);
-- 1.5.5.rc1.178.gd799d