Skip to content

Commit 5e56a39

Browse files
committed
Merge branch 'ps/config-wo-the-repository'
Use of API functions that implicitly depend on the_repository object in the config subsystem has been rewritten to pass a repository object through the callchain. * ps/config-wo-the-repository: config: hide functions using `the_repository` by default global: prepare for hiding away repo-less config functions config: don't depend on `the_repository` with branch conditions config: don't have setters depend on `the_repository` config: pass repo to functions that rename or copy sections config: pass repo to `git_die_config()` config: pass repo to `git_config_get_expiry_in_days()` config: pass repo to `git_config_get_expiry()` config: pass repo to `git_config_get_max_percent_split_change()` config: pass repo to `git_config_get_split_index()` config: pass repo to `git_config_get_index_threads()` config: expose `repo_config_clear()` config: introduce missing setters that take repo as parameter path: hide functions using `the_repository` by default path: stop relying on `the_repository` in `worktree_git_path()` path: stop relying on `the_repository` when reporting garbage hooks: remove implicit dependency on `the_repository` editor: do not rely on `the_repository` for interactive edits path: expose `do_git_common_path()` as `repo_common_pathv()` path: expose `do_git_path()` as `repo_git_pathv()`
2 parents 1b6b2bf + 036876a commit 5e56a39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+570
-457
lines changed

add-patch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
11421142
"removed, then the edit is\n"
11431143
"aborted and the hunk is left unchanged.\n"));
11441144

1145-
if (strbuf_edit_interactively(&s->buf, "addp-hunk-edit.diff", NULL) < 0)
1145+
if (strbuf_edit_interactively(the_repository, &s->buf,
1146+
"addp-hunk-edit.diff", NULL) < 0)
11461147
return -1;
11471148

11481149
/* strip out commented lines */

builtin/am.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ static int run_applypatch_msg_hook(struct am_state *state)
490490
assert(state->msg);
491491

492492
if (!state->no_verify)
493-
ret = run_hooks_l("applypatch-msg", am_path(state, "final-commit"), NULL);
493+
ret = run_hooks_l(the_repository, "applypatch-msg",
494+
am_path(state, "final-commit"), NULL);
494495

495496
if (!ret) {
496497
FREE_AND_NULL(state->msg);
@@ -512,7 +513,7 @@ static int run_post_rewrite_hook(const struct am_state *state)
512513
strvec_push(&opt.args, "rebase");
513514
opt.path_to_stdin = am_path(state, "rewritten");
514515

515-
return run_hooks_opt("post-rewrite", &opt);
516+
return run_hooks_opt(the_repository, "post-rewrite", &opt);
516517
}
517518

518519
/**
@@ -1663,7 +1664,7 @@ static void do_commit(const struct am_state *state)
16631664
const char *reflog_msg, *author, *committer = NULL;
16641665
struct strbuf sb = STRBUF_INIT;
16651666

1666-
if (!state->no_verify && run_hooks("pre-applypatch"))
1667+
if (!state->no_verify && run_hooks(the_repository, "pre-applypatch"))
16671668
exit(1);
16681669

16691670
if (write_index_as_tree(&tree, the_repository->index, get_index_file(), 0, NULL))
@@ -1716,7 +1717,7 @@ static void do_commit(const struct am_state *state)
17161717
fclose(fp);
17171718
}
17181719

1719-
run_hooks("post-applypatch");
1720+
run_hooks(the_repository, "post-applypatch");
17201721

17211722
free_commit_list(parents);
17221723
strbuf_release(&sb);

builtin/branch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void delete_branch_config(const char *branchname)
210210
{
211211
struct strbuf buf = STRBUF_INIT;
212212
strbuf_addf(&buf, "branch.%s", branchname);
213-
if (git_config_rename_section(buf.buf, NULL) < 0)
213+
if (repo_config_rename_section(the_repository, buf.buf, NULL) < 0)
214214
warning(_("update of config-file failed"));
215215
strbuf_release(&buf);
216216
}
@@ -659,9 +659,10 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
659659

660660
strbuf_addf(&oldsection, "branch.%s", interpreted_oldname);
661661
strbuf_addf(&newsection, "branch.%s", interpreted_newname);
662-
if (!copy && git_config_rename_section(oldsection.buf, newsection.buf) < 0)
662+
if (!copy && repo_config_rename_section(the_repository, oldsection.buf, newsection.buf) < 0)
663663
die(_("branch is renamed, but update of config-file failed"));
664-
if (copy && strcmp(interpreted_oldname, interpreted_newname) && git_config_copy_section(oldsection.buf, newsection.buf) < 0)
664+
if (copy && strcmp(interpreted_oldname, interpreted_newname) &&
665+
repo_config_copy_section(the_repository, oldsection.buf, newsection.buf) < 0)
665666
die(_("branch is copied, but update of config-file failed"));
666667
strbuf_release(&oldref);
667668
strbuf_release(&newref);

builtin/bugreport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit)
5858
for (p = hook_name_list; *p; p++) {
5959
const char *hook = *p;
6060

61-
if (hook_exists(hook))
61+
if (hook_exists(the_repository, hook))
6262
strbuf_addf(hook_info, "%s\n", hook);
6363
}
6464
}

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void branch_info_release(struct branch_info *info)
125125
static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
126126
int changed)
127127
{
128-
return run_hooks_l("post-checkout",
128+
return run_hooks_l(the_repository, "post-checkout",
129129
oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
130130
oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
131131
changed ? "1" : "0", NULL);

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ static int checkout(int submodule_progress, int filter_submodules,
789789
if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
790790
die(_("unable to write new index file"));
791791

792-
err |= run_hooks_l("post-checkout", oid_to_hex(null_oid()),
792+
err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid()),
793793
oid_to_hex(&oid), "1", NULL);
794794

795795
if (!err && (option_recurse_submodules.nr > 0)) {

builtin/config.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,8 @@ static int cmd_config_rename_section(int argc, const char **argv, const char *pr
10261026
location_options_init(&location_opts, prefix);
10271027
check_write(&location_opts.source);
10281028

1029-
ret = git_config_rename_section_in_file(location_opts.source.file,
1030-
argv[0], argv[1]);
1029+
ret = repo_config_rename_section_in_file(the_repository, location_opts.source.file,
1030+
argv[0], argv[1]);
10311031
if (ret < 0)
10321032
goto out;
10331033
else if (!ret)
@@ -1055,8 +1055,8 @@ static int cmd_config_remove_section(int argc, const char **argv, const char *pr
10551055
location_options_init(&location_opts, prefix);
10561056
check_write(&location_opts.source);
10571057

1058-
ret = git_config_rename_section_in_file(location_opts.source.file,
1059-
argv[0], NULL);
1058+
ret = repo_config_rename_section_in_file(the_repository, location_opts.source.file,
1059+
argv[0], NULL);
10601060
if (ret < 0)
10611061
goto out;
10621062
else if (!ret)
@@ -1353,8 +1353,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13531353
else if (actions == ACTION_RENAME_SECTION) {
13541354
check_write(&location_opts.source);
13551355
check_argc(argc, 2, 2);
1356-
ret = git_config_rename_section_in_file(location_opts.source.file,
1357-
argv[0], argv[1]);
1356+
ret = repo_config_rename_section_in_file(the_repository, location_opts.source.file,
1357+
argv[0], argv[1]);
13581358
if (ret < 0)
13591359
goto out;
13601360
else if (!ret)
@@ -1365,8 +1365,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13651365
else if (actions == ACTION_REMOVE_SECTION) {
13661366
check_write(&location_opts.source);
13671367
check_argc(argc, 1, 1);
1368-
ret = git_config_rename_section_in_file(location_opts.source.file,
1369-
argv[0], NULL);
1368+
ret = repo_config_rename_section_in_file(the_repository, location_opts.source.file,
1369+
argv[0], NULL);
13701370
if (ret < 0)
13711371
goto out;
13721372
else if (!ret)

builtin/count-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
113113
usage_with_options(count_objects_usage, opts);
114114
if (verbose) {
115115
report_garbage = real_report_garbage;
116-
report_linked_checkout_garbage();
116+
report_linked_checkout_garbage(the_repository);
117117
}
118118

119119
for_each_loose_file_in_objdir(get_object_directory(),

builtin/fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,8 +3485,8 @@ static void git_pack_config(void)
34853485
if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
34863486
pack_idx_opts.version = indexversion_value;
34873487
if (pack_idx_opts.version > 2)
3488-
git_die_config("pack.indexversion",
3489-
"bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
3488+
git_die_config(the_repository, "pack.indexversion",
3489+
"bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
34903490
}
34913491
if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
34923492
max_packsize = packsizelimit_value;

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
10531053
* and may get overwritten by other calls
10541054
* while we're examining the index.
10551055
*/
1056-
path = xstrdup(worktree_git_path(wt, "index"));
1056+
path = xstrdup(worktree_git_path(the_repository, wt, "index"));
10571057
read_index_from(&istate, path, get_worktree_git_dir(wt));
10581058
fsck_index(&istate, path, wt->is_current);
10591059
discard_index(&istate);

0 commit comments

Comments
 (0)