if (!common_dir)
return error(_("unable to get common directory"));
- format_path(buf, common_dir, startup_info->prefix, PATH_FORMAT_CANONICAL);
+ format_path(buf, common_dir, repo->prefix, PATH_FORMAT_CANONICAL);
return 0;
}
if (!common_dir)
return error(_("unable to get common directory"));
- format_path(buf, common_dir, startup_info->prefix, PATH_FORMAT_RELATIVE);
+ format_path(buf, common_dir, repo->prefix, PATH_FORMAT_RELATIVE);
return 0;
}
if (!git_dir)
return error(_("unable to get git directory"));
- format_path(buf, git_dir, startup_info->prefix, PATH_FORMAT_CANONICAL);
+ format_path(buf, git_dir, repo->prefix, PATH_FORMAT_CANONICAL);
return 0;
}
if (!git_dir)
return error(_("unable to get git directory"));
- format_path(buf, git_dir, startup_info->prefix, PATH_FORMAT_RELATIVE);
+ format_path(buf, git_dir, repo->prefix, PATH_FORMAT_RELATIVE);
return 0;
}
show_default();
if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
if (output_prefix) {
- const char *prefix = startup_info->prefix;
+ const char *prefix = the_repository->prefix;
char *fname = prefix_filename(prefix, arg);
show(fname);
free(fname);
prefix = argv[++i];
if (!prefix)
die(_("--prefix requires an argument"));
- startup_info->prefix = prefix;
+ FREE_AND_NULL(the_repository->prefix);
+ the_repository->prefix = xstrdup(prefix);
output_prefix = 1;
continue;
}
const char *arg, int unset)
{
int *has_errors = opt->value;
- const char *prefix = startup_info->prefix;
+ const char *prefix = the_repository->prefix;
BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);
const char *arg, int unset)
{
int *has_errors = opt->value;
- const char *prefix = startup_info->prefix;
+ const char *prefix = the_repository->prefix;
BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);
die(_("relative path syntax can't be used outside working tree"));
/* die() inside prefix_path() if resolved path is outside worktree */
- return prefix_path(the_repository, startup_info->prefix,
- startup_info->prefix ? strlen(startup_info->prefix) : 0,
+ return prefix_path(the_repository, the_repository->prefix,
+ the_repository->prefix ? strlen(the_repository->prefix) : 0,
rel);
}
FREE_AND_NULL(repo->gitdir);
FREE_AND_NULL(repo->commondir);
+ FREE_AND_NULL(repo->prefix);
FREE_AND_NULL(repo->graft_file);
FREE_AND_NULL(repo->index_file);
FREE_AND_NULL(repo->worktree);
*/
char *commondir;
+ /*
+ * The "prefix", a path to the current working directory relative to
+ * the work tree root, or NULL, if the current working directory is not
+ * a strict subdirectory of the work tree root. The prefix always ends
+ * with a '/' character.
+ */
+ char *prefix;
+
/*
* Holds any information related to accessing the raw object content.
*/
* repository and that the caller expects startup_info to reflect
* this.
*
- * Regardless of the state of nongit_ok, startup_info->prefix and
+ * Regardless of the state of nongit_ok, the_repository->prefix and
* the GIT_PREFIX environment variable must always match. For details
* see Documentation/config/alias.adoc.
*/
*/
if (prefix) {
prefix = precompose_string_if_needed(prefix);
- startup_info->prefix = prefix;
+ repo->prefix = xstrdup(prefix);
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
} else {
- startup_info->prefix = NULL;
+ FREE_AND_NULL(repo->prefix);
setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
}
bool force_bare_repository;
int have_repository;
- const char *prefix;
const char *original_cwd;
};
extern struct startup_info *startup_info;
void trace_repo_setup(struct repository *r)
{
- const char *git_work_tree, *prefix = startup_info->prefix;
+ const char *git_work_tree, *prefix = r->prefix;
char *cwd;
if (!trace_want(&trace_setup_key))
if (!(git_work_tree = repo_get_work_tree(r)))
git_work_tree = "(null)";
- if (!startup_info->prefix)
+ if (!r->prefix)
prefix = "(null)";
trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(repo_get_git_dir(r)));