return 0;
}
-static int get_path_git_prefix(struct repository *repo UNUSED, struct strbuf *buf)
++static int get_path_git_prefix(struct repository *repo, struct strbuf *buf)
+ {
+ /*
- * startup_info->prefix is NULL if we are at the working tree root.
++ * repo->prefix is NULL if we are at the working tree root.
+ * We add an empty string to ensure the buffer is cleanly initialized.
+ */
- strbuf_addstr(buf, startup_info->prefix ? startup_info->prefix : "");
++ strbuf_addstr(buf, repo->prefix ? repo->prefix : "");
+ return 0;
+ }
+
static int get_path_gitdir_absolute(struct repository *repo, struct strbuf *buf)
{
const char *git_dir = repo_get_git_dir(repo);
return 0;
}
- format_path(buf, graft_file, startup_info->prefix, PATH_FORMAT_CANONICAL);
+ static int get_path_grafts_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ const char *graft_file = repo_get_graft_file(repo);
+
+ if (!graft_file)
+ return error(_("unable to get graft file"));
+
- format_path(buf, graft_file, startup_info->prefix, PATH_FORMAT_RELATIVE);
++ format_path(buf, graft_file, repo->prefix, PATH_FORMAT_CANONICAL);
+ return 0;
+ }
+
+ static int get_path_grafts_relative(struct repository *repo, struct strbuf *buf)
+ {
+ const char *graft_file = repo_get_graft_file(repo);
+
+ if (!graft_file)
+ return error(_("unable to get graft file"));
+
- format_path(buf, hooks_path.buf, startup_info->prefix, PATH_FORMAT_CANONICAL);
++ format_path(buf, graft_file, repo->prefix, PATH_FORMAT_RELATIVE);
+ return 0;
+ }
+
+ static int get_path_hooks_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ struct strbuf hooks_path = STRBUF_INIT;
+
+ repo_git_path_replace(repo, &hooks_path, "hooks");
- format_path(buf, hooks_path.buf, startup_info->prefix, PATH_FORMAT_RELATIVE);
++ format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_CANONICAL);
+ strbuf_release(&hooks_path);
+ return 0;
+ }
+
+ static int get_path_hooks_relative(struct repository *repo, struct strbuf *buf)
+ {
+ struct strbuf hooks_path = STRBUF_INIT;
+
+ repo_git_path_replace(repo, &hooks_path, "hooks");
- format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_CANONICAL);
++ format_path(buf, hooks_path.buf, repo->prefix, PATH_FORMAT_RELATIVE);
+ strbuf_release(&hooks_path);
+ return 0;
+ }
+
+ static int get_path_index_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ const char *index_file = repo_get_index_file(repo);
+
+ if (!index_file)
+ return error(_("unable to get index file"));
+
- format_path(buf, index_file, startup_info->prefix, PATH_FORMAT_RELATIVE);
++ format_path(buf, index_file, repo->prefix, PATH_FORMAT_CANONICAL);
+ return 0;
+ }
+
+ static int get_path_index_relative(struct repository *repo, struct strbuf *buf)
+ {
+ const char *index_file = repo_get_index_file(repo);
+
+ if (!index_file)
+ return error(_("unable to get index file"));
+
- format_path(buf, obj_dir, startup_info->prefix, PATH_FORMAT_CANONICAL);
++ format_path(buf, index_file, repo->prefix, PATH_FORMAT_RELATIVE);
+ return 0;
+ }
+
+ static int get_path_objects_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ const char *obj_dir = repo_get_object_directory(repo);
+
+ if (!obj_dir)
+ return error(_("unable to get object directory"));
+
- format_path(buf, obj_dir, startup_info->prefix, PATH_FORMAT_RELATIVE);
++ format_path(buf, obj_dir, repo->prefix, PATH_FORMAT_CANONICAL);
+ return 0;
+ }
+
+ static int get_path_objects_relative(struct repository *repo, struct strbuf *buf)
+ {
+ const char *obj_dir = repo_get_object_directory(repo);
+
+ if (!obj_dir)
+ return error(_("unable to get object directory"));
+
-static int get_path_superproject_absolute(struct repository *repo UNUSED, struct strbuf *buf)
++ format_path(buf, obj_dir, repo->prefix, PATH_FORMAT_RELATIVE);
+ return 0;
+ }
+
- format_path(buf, superproject.buf, startup_info->prefix, PATH_FORMAT_CANONICAL);
++static int get_path_superproject_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ struct strbuf superproject = STRBUF_INIT;
+
+ if (!get_superproject_working_tree(&superproject)) {
+ strbuf_release(&superproject);
+ strbuf_addstr(buf, "");
+ return 0;
+ }
+
-static int get_path_superproject_relative(struct repository *repo UNUSED, struct strbuf *buf)
++ format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_CANONICAL);
+ strbuf_release(&superproject);
+ return 0;
+ }
+
- format_path(buf, superproject.buf, startup_info->prefix, PATH_FORMAT_RELATIVE);
++static int get_path_superproject_relative(struct repository *repo, struct strbuf *buf)
+ {
+ struct strbuf superproject = STRBUF_INIT;
+
+ if (!get_superproject_working_tree(&superproject)) {
+ strbuf_release(&superproject);
+ strbuf_addstr(buf, "");
+ return 0;
+ }
+
- format_path(buf, work_tree, startup_info->prefix, PATH_FORMAT_CANONICAL);
++ format_path(buf, superproject.buf, repo->prefix, PATH_FORMAT_RELATIVE);
+ strbuf_release(&superproject);
+ return 0;
+ }
+
+ static int get_path_toplevel_absolute(struct repository *repo, struct strbuf *buf)
+ {
+ const char *work_tree = repo_get_work_tree(repo);
+
+ if (!work_tree) {
+ strbuf_addstr(buf, "");
+ return 0;
+ }
+
- format_path(buf, work_tree, startup_info->prefix, PATH_FORMAT_RELATIVE);
++ format_path(buf, work_tree, repo->prefix, PATH_FORMAT_CANONICAL);
+ return 0;
+ }
+
+ static int get_path_toplevel_relative(struct repository *repo, struct strbuf *buf)
+ {
+ const char *work_tree = repo_get_work_tree(repo);
+
+ if (!work_tree) {
+ strbuf_addstr(buf, "");
+ return 0;
+ }
+
++ format_path(buf, work_tree, repo->prefix, PATH_FORMAT_RELATIVE);
+ return 0;
+ }
+
static int get_references_format(struct repository *repo, struct strbuf *buf)
{
strbuf_addstr(buf,