Signed-off-by: Matthias Lederhofer <matled@xxxxxxx> --- It's much easier when $GIT_WORK_DIR is always interpreted relative to $GIT_DIR. --- builtin-init-db.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/builtin-init-db.c b/builtin-init-db.c index 4df9fd0..8d0065c 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -182,6 +182,7 @@ static int create_default_files(const char *git_dir, const char *template_path) char repo_version_string[10]; int reinit; int filemode; + const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT); if (len > sizeof(path)-50) die("insane git directory %s", git_dir); @@ -252,10 +253,21 @@ static int create_default_files(const char *git_dir, const char *template_path) } git_config_set("core.filemode", filemode ? "true" : "false"); - if (is_bare_repository()) { + if (is_bare_repository() && !gitwd) { git_config_set("core.bare", "true"); } else { + if (gitwd) { + FILE *fp = NULL; + + path[len] = 0; + strcpy(path + len, "workdir"); + if (!(fp = fopen(path, "w"))) + die("Cannot open GIT_DIR/workdir"); + fprintf(fp, "%s\n", gitwd); + fclose(fp); + } + git_config_set("core.bare", "false"); /* allow template config file to override the default */ if (log_all_ref_updates == -1) -- 1.5.0.3.1007.g7ff7 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html