git/builtin
Patrick Steinhardt bd2851d84f setup: stop using `the_repository` in `setup_work_tree()`
Stop using `the_repository` in `setup_work_tree()` and instead accept
the repository as a parameter. The injection of `the_repository` is thus
bumped one level higher, where callers now pass it in explicitly.

Note that the function tracks two bits of information via global
variables. This of course doesn't make much sense anymore now that we
can set up worktrees for arbitrary repositories:

  - We track whether the worktree has already been initialized and, if
    so, we skip the call to `chdir_notify()` and setenv(3p). It does not
    make much sense to store this info in the repository, as we _would_
    want to update the environment when switching between worktrees back
    and forth.

    So instead of storing this info in the repository, we drop this
    state entirely and live with the fact that we may execute the logic
    twice. It should ultimately be idempotent though and thus not be
    much of a problem.

  - We track whether the worktree configuration is bogus. If so, and if
    later on some caller tries to setup the worktree, then we'll die
    instead. This is indeed information that we can move into the
    repository itself.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-05-19 19:36:24 +09:00
..
add.c Merge branch 'ps/history-split' 2026-03-24 12:31:32 -07:00
am.c hook: mark non-parallelizable hooks 2026-04-10 07:58:53 -07:00
annotate.c
apply.c
archive.c
backfill.c backfill: default to grabbing edge blobs too 2026-04-15 20:32:29 -07:00
bisect.c refs: replace `refs_for_each_glob_ref_in()` 2026-02-23 13:21:19 -08:00
blame.c setup: stop using `the_repository` in `prefix_path()` 2026-05-19 19:36:24 +09:00
branch.c object-name: turn INTERPRET_BRANCH_* constants into enum values 2026-03-18 12:52:29 -07:00
bugreport.c
bundle.c
cat-file.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
check-attr.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
check-ignore.c
check-mailmap.c mailmap: stop using the_repository 2026-02-20 08:13:58 -08:00
check-ref-format.c
checkout--worker.c
checkout-index.c setup: stop using `the_repository` in `prefix_path()` 2026-05-19 19:36:24 +09:00
checkout.c setup: stop using `the_repository` in `verify_non_filename()` 2026-05-19 19:36:24 +09:00
clean.c
clone.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
column.c
commit-graph.c commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
commit-tree.c commit: rename `free_commit_list()` to conform to coding guidelines 2026-01-15 05:32:31 -08:00
commit.c sequencer: teach autostash apply to take optional conflict marker labels 2026-04-29 21:46:03 +09:00
config.c config: store allocated string in non-const pointer 2026-03-26 12:47:17 -07:00
count-objects.c packfile: introduce macro to iterate through packs 2025-10-16 14:42:39 -07:00
credential-cache--daemon.c
credential-cache.c
credential-store.c builtin/credential-store: move is_rfc3986_unreserved to url.[ch] 2026-01-12 11:56:56 -08:00
credential.c
describe.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
diagnose.c
diff-files.c
diff-index.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
diff-pairs.c
diff-tree.c Merge branch 'ps/commit-list-functions-renamed' 2026-02-13 13:39:25 -08:00
diff.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
difftool.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
fast-export.c fast-import: add 'abort-if-invalid' mode to '--signed-commits=<mode>' 2026-03-26 12:42:57 -07:00
fast-import.c Merge branch 'jt/fast-import-signed-modes' 2026-04-07 14:59:27 -07:00
fetch-pack.c
fetch.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
fmt-merge-msg.c
for-each-ref.c
for-each-repo.c for-each-repo: simplify passing of parameters 2026-03-03 10:20:00 -08:00
fsck.c Merge branch 'ps/odb-cleanup' 2026-04-08 10:19:17 -07:00
fsmonitor--daemon.c
gc.c maintenance(geometric): do release the `.idx` files before repacking 2026-05-08 09:53:12 +09:00
get-tar-commit-id.c
grep.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
hash-object.c
help.c Merge branch 'ac/help-sort-correctly' 2026-03-23 09:20:30 -07:00
history.c history: fix short help for argument of --update-refs 2026-04-06 10:17:36 -07:00
hook.c hook: allow hook.jobs=-1 to use all available CPU cores 2026-04-10 07:58:55 -07:00
index-pack.c Merge branch 'ps/odb-cleanup' 2026-04-08 10:19:17 -07:00
init-db.c
interpret-trailers.c Merge branch 'kh/doc-interpret-trailers-1' 2026-03-27 11:00:02 -07:00
last-modified.c Merge branch 'tc/last-modified-not-a-tree' 2026-02-13 13:39:25 -08:00
log.c Merge branch 'mf/format-patch-cover-letter-format' 2026-04-03 13:01:08 -07:00
ls-files.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
ls-remote.c ref-filter: propagate peeled object ID 2025-11-04 07:32:25 -08:00
ls-tree.c cocci: convert parse_tree functions to repo_ variants 2026-01-09 18:36:18 -08:00
mailinfo.c
mailsplit.c
merge-base.c commit: rename `free_commit_list()` to conform to coding guidelines 2026-01-15 05:32:31 -08:00
merge-file.c Merge branch 'mr/merge-file-object-id-worktree-fix' 2026-03-27 11:00:01 -07:00
merge-index.c
merge-ours.c merge-ours: integrate with sparse-index 2026-02-06 11:45:33 -08:00
merge-recursive.c
merge-tree.c Merge branch 'ps/commit-list-functions-renamed' 2026-02-13 13:39:25 -08:00
merge.c sequencer: teach autostash apply to take optional conflict marker labels 2026-04-29 21:46:03 +09:00
mktag.c fsck: store repository in fsck options 2026-03-23 08:33:10 -07:00
mktree.c builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE 2026-03-12 10:03:23 -07:00
multi-pack-index.c Merge branch 'ps/object-counting' 2026-03-25 12:58:05 -07:00
mv.c setup: stop using `the_repository` in `prefix_path()` 2026-05-19 19:36:24 +09:00
name-rev.c use commit_stack instead of prio_queue in LIFO mode 2026-03-18 10:39:56 -07:00
notes.c
pack-objects.c Merge branch 'tb/stdin-packs-excluded-but-open' 2026-04-06 15:42:49 -07:00
pack-redundant.c pack-redundant: fix memory leak when open_pack_index() fails 2026-02-21 21:26:53 -08:00
pack-refs.c
patch-id.c patch-id: use “patch ID” throughout 2026-01-09 06:07:21 -08:00
prune-packed.c
prune.c
pull.c run-command: wean start_command() off the_repository 2026-03-12 08:30:57 -07:00
push.c environment: move "branch.autoSetupMerge" into `struct repo_config_values` 2026-02-26 07:22:53 -08:00
range-diff.c
read-tree.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
rebase.c use strvec_pushv() to add another strvec 2026-03-24 12:26:58 -07:00
receive-pack.c setup: stop using `the_repository` in `enter_repo()` 2026-05-19 19:36:24 +09:00
reflog.c
refs.c fsck: store repository in fsck options 2026-03-23 08:33:10 -07:00
remote-ext.c
remote-fd.c
remote.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
repack.c repack: mark non-MIDX packs above the split as excluded-open 2026-03-27 13:40:40 -07:00
replace.c refs: introduce wrapper struct for `each_ref_fn` 2025-11-04 07:32:24 -08:00
replay.c replay: allow to specify a ref with option --ref 2026-04-01 21:34:25 -07:00
repo.c repo: show subcommand-specific help text 2026-03-25 10:35:27 -07:00
rerere.c
reset.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
rev-list.c rev-list: use reduce_heads() for --maximal-only 2026-04-06 12:02:30 -07:00
rev-parse.c setup: stop using `the_repository` in `verify_filename()` 2026-05-19 19:36:24 +09:00
revert.c
rm.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
send-pack.c
shortlog.c mailmap: stop using the_repository 2026-02-20 08:13:58 -08:00
show-branch.c commit: rename `free_commit_list()` to conform to coding guidelines 2026-01-15 05:32:31 -08:00
show-index.c show-index: use gettext wrapping in user facing error messages 2026-01-30 08:58:12 -08:00
show-ref.c odb: rename `odb_has_object()` flags 2026-03-31 20:43:14 -07:00
sparse-checkout.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
stash.c stash: add --label-ours, --label-theirs, --label-base for apply 2026-04-29 21:46:02 +09:00
stripspace.c
submodule--helper.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
symbolic-ref.c
tag.c Merge branch 'jt/fast-import-sign-again' 2026-03-24 12:31:31 -07:00
unpack-file.c
unpack-objects.c Merge branch 'ps/odb-cleanup' 2026-04-08 10:19:17 -07:00
update-index.c setup: stop using `the_repository` in `setup_work_tree()` 2026-05-19 19:36:24 +09:00
update-ref.c update-ref: utilize rejected error details if available 2026-01-25 22:27:33 -08:00
update-server-info.c
upload-archive.c setup: stop using `the_repository` in `enter_repo()` 2026-05-19 19:36:24 +09:00
upload-pack.c setup: stop using `the_repository` in `enter_repo()` 2026-05-19 19:36:24 +09:00
var.c
verify-commit.c
verify-pack.c
verify-tag.c tag: support arbitrary repositories in gpg_verify_tag() 2025-12-29 22:02:53 +09:00
worktree.c hook: mark non-parallelizable hooks 2026-04-10 07:58:53 -07:00
write-tree.c