return git_config_pathname(&git_attributes_file, var, value);
}
- if (!strcmp(var, "core.hookspath")) {
- FREE_AND_NULL(git_hooks_path);
- return git_config_pathname(&git_hooks_path, var, value);
- }
-
if (!strcmp(var, "core.bare")) {
is_bare_repository_cfg = git_config_bool(var, value);
return 0;
char *apply_default_whitespace;
char *apply_default_ignorewhitespace;
char *git_attributes_file;
-char *git_hooks_path;
int zlib_compression_level = Z_BEST_SPEED;
int pack_compression_level = Z_DEFAULT_COMPRESSION;
int fsync_object_files = -1;
extern char *apply_default_whitespace;
extern char *apply_default_ignorewhitespace;
extern char *git_attributes_file;
-extern char *git_hooks_path;
extern int zlib_compression_level;
extern int pack_compression_level;
extern size_t packed_git_window_size;
strbuf_release(&sb);
}
-static void adjust_git_path(const struct repository *repo,
+static void adjust_git_path(struct repository *repo,
struct strbuf *buf, int git_dir_len)
{
const char *base = buf->buf + git_dir_len;
+
if (is_dir_file(base, "info", "grafts"))
strbuf_splice(buf, 0, buf->len,
repo->graft_file, strlen(repo->graft_file));
repo->index_file, strlen(repo->index_file));
else if (dir_prefix(base, "objects"))
replace_dir(buf, git_dir_len + 7, repo->objects->odb->path);
- else if (git_hooks_path && dir_prefix(base, "hooks"))
- replace_dir(buf, git_dir_len + 5, git_hooks_path);
+ else if (repo_settings_get_hooks_path(repo) && dir_prefix(base, "hooks"))
+ replace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo));
else if (repo->different_commondir)
update_common_dir(buf, git_dir_len, repo->commondir);
}
repo_common_path_append(repo, buf, "worktrees/%s", wt->id);
}
-static void repo_git_pathv(const struct repository *repo,
+static void repo_git_pathv(struct repository *repo,
const struct worktree *wt, struct strbuf *buf,
const char *fmt, va_list args)
{
strbuf_cleanup_path(buf);
}
-char *repo_git_path(const struct repository *repo,
+char *repo_git_path(struct repository *repo,
const char *fmt, ...)
{
struct strbuf path = STRBUF_INIT;
return strbuf_detach(&path, NULL);
}
-const char *repo_git_path_append(const struct repository *repo,
+const char *repo_git_path_append(struct repository *repo,
struct strbuf *sb,
const char *fmt, ...)
{
return sb->buf;
}
-const char *repo_git_path_replace(const struct repository *repo,
+const char *repo_git_path_replace(struct repository *repo,
struct strbuf *sb,
const char *fmt, ...)
{
* For an exhaustive list of the adjustments made look at `common_list` and
* `adjust_git_path` in path.c.
*/
-char *repo_git_path(const struct repository *repo,
+char *repo_git_path(struct repository *repo,
const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
-const char *repo_git_path_append(const struct repository *repo,
+const char *repo_git_path_append(struct repository *repo,
struct strbuf *sb,
const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
-const char *repo_git_path_replace(const struct repository *repo,
+const char *repo_git_path_replace(struct repository *repo,
struct strbuf *sb,
const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
{
struct repo_settings empty = REPO_SETTINGS_INIT;
FREE_AND_NULL(r->settings.fsmonitor);
+ FREE_AND_NULL(r->settings.hooks_path);
r->settings = empty;
}
&repo->settings.warn_ambiguous_refs, 1);
return repo->settings.warn_ambiguous_refs;
}
+
+const char *repo_settings_get_hooks_path(struct repository *repo)
+{
+ if (!repo->settings.hooks_path)
+ repo_config_get_pathname(repo, "core.hookspath", &repo->settings.hooks_path);
+ return repo->settings.hooks_path;
+}
size_t delta_base_cache_limit;
size_t packed_git_window_size;
size_t packed_git_limit;
+
+ char *hooks_path;
};
#define REPO_SETTINGS_INIT { \
.index_version = -1, \
enum log_refs_config repo_settings_get_log_all_ref_updates(struct repository *repo);
/* Read the value for "core.warnAmbiguousRefs". */
int repo_settings_get_warn_ambiguous_refs(struct repository *repo);
+/* Read the value for "core.hooksPath". */
+const char *repo_settings_get_hooks_path(struct repository *repo);
#endif /* REPO_SETTINGS_H */