const char *replace_ref_base;
git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir)
+ if (!git_dir) {
+ if (!startup_info->have_repository)
+ die("BUG: setup_git_env called without repository");
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ }
gitfile = read_gitfile(git_dir);
git_dir = xstrdup(gitfile ? gitfile : git_dir);
if (get_common_dir(&sb, git_dir))
const char *get_git_common_dir(void)
{
+ if (!git_dir)
+ setup_git_env();
return git_common_dir;
}
* restrictive except to remove write permission.
*/
int mode = 0444;
- strbuf_reset(template);
- strbuf_addf(template, "%s/%s", get_object_directory(), pattern);
+ git_path_buf(template, "objects/%s", pattern);
fd = git_mkstemp_mode(template->buf, mode);
if (0 <= fd)
return fd;
/* slow path */
/* some mkstemp implementations erase template on failure */
- strbuf_reset(template);
- strbuf_addf(template, "%s/%s", get_object_directory(), pattern);
+ git_path_buf(template, "objects/%s", pattern);
safe_create_leading_directories(template->buf);
return xmkstemp_mode(template->buf, mode);
}