git/builtin
Patrick Steinhardt 8f4c00de95 builtin/worktree: create refdb via ref backend
When creating a worktree we create the worktree's ref database manually
by first writing a "HEAD" file so that the directory is recognized as a
Git repository by other commands, and then running git-update-ref(1) or
git-symbolic-ref(1) to write the actual value. But while this is fine
for the files backend, this logic simply assumes too much about how the
ref backend works and will leave behind an invalid ref database once any
other ref backend lands.

Refactor the code to instead use `refs_init_db()` to initialize the ref
database so that git-worktree(1) itself does not need to know about how
to initialize it. This will allow future ref backends to customize how
the per-worktree ref database is set up. Furthermore, as we now already
have a worktree ref store around, we can also avoid spawning external
commands to write the HEAD reference and instead use the refs API to do
so.

Note that we do not have an equivalent to passing the `--quiet` flag to
git-symbolic-ref(1) as we did before. This flag does not have an effect
anyway though, as git-symbolic-ref(1) only honors it when reading a
symref, but never when writing one.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-08 13:17:30 -08:00
..
add.c attr: enable attr pathspec magic for git-add and git-stash 2023-11-04 17:00:27 +09:00
am.c Merge branch 'rs/fix-arghelp' 2023-11-07 10:26:43 +09:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
archive.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
bisect.c Merge branch 'jk/bisect-reset-fix' 2023-12-20 10:14:54 -08:00
blame.c config: handle NULL value when parsing non-bools 2023-12-09 08:24:39 +09:00
branch.c Merge branch 'vd/for-each-ref-unsorted-optimization' 2023-12-09 16:37:50 -08:00
bugreport.c bugreport: reject positional arguments 2023-10-29 08:56:17 +09:00
bundle.c Merge branch 'rs/bundle-parseopt-cleanup' 2023-08-07 11:57:18 -07:00
cat-file.c doc/cat-file: make synopsis and description less confusing 2023-10-09 12:46:33 -07:00
check-attr.c check-attr: integrate with sparse-index 2023-08-11 09:44:52 -07:00
check-ignore.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
check-mailmap.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
check-ref-format.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
checkout--worker.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
checkout-index.c parse-options: prefer opt->value to globals in callbacks 2023-09-05 14:48:17 -07:00
checkout.c config: handle NULL value when parsing non-bools 2023-12-09 08:24:39 +09:00
clean.c clean: factorize incompatibility message 2023-12-09 07:41:03 +09:00
clone.c builtin/clone: introduce --ref-format= value flag 2024-01-02 09:24:48 -08:00
column.c Merge branch 'rs/column-leakfix' 2023-12-18 14:10:13 -08:00
commit-graph.c Merge branch 'jk/commit-graph-leak-fixes' 2023-10-13 14:18:28 -07:00
commit-tree.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
commit.c Merge branch 'jc/commit-new-underscore-index-fix' into maint-2.42 2023-11-02 16:53:28 +09:00
config.c Merge branch 'cw/compat-util-header-cleanup' 2023-07-17 11:30:42 -07:00
count-objects.c count-objects: mark unused parameter in alternates callback 2023-07-13 17:24:00 -07:00
credential-cache--daemon.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
credential-cache.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
credential-store.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
credential.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
describe.c Merge branch 'jk/unused-post-2.42-part2' 2023-09-13 10:07:56 -07:00
diagnose.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
diff-files.c diff: drop useless "status" parameter from diff_result_code() 2023-08-21 15:33:24 -07:00
diff-index.c diff: drop useless "status" parameter from diff_result_code() 2023-08-21 15:33:24 -07:00
diff-tree.c diff: drop useless "status" parameter from diff_result_code() 2023-08-21 15:33:24 -07:00
diff.c diff --stat: set the width defaults in a helper function 2023-09-29 15:46:06 -07:00
difftool.c Merge branch 'cw/compat-util-header-cleanup' 2023-07-17 11:30:42 -07:00
fast-export.c parse-options: prefer opt->value to globals in callbacks 2023-09-05 14:48:17 -07:00
fast-import.c Merge branch 'ew/hash-with-openssl-evp' 2023-09-13 10:07:57 -07:00
fetch-pack.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
fetch.c Merge branch 'jk/unused-post-2.42-part2' 2023-09-13 10:07:56 -07:00
fmt-merge-msg.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
for-each-ref.c ref-filter.h: add functions for filter/format & format-only 2023-11-16 14:02:59 +09:00
for-each-repo.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
fsck.c fsck: use enum object_type for fsck_walk callback 2023-08-19 21:17:32 -07:00
fsmonitor--daemon.c run-command: mark unused parameters in start_bg_wait callbacks 2023-09-18 15:56:15 -07:00
gc.c Merge branch 'tb/repack-max-cruft-size' 2023-10-18 13:25:41 -07:00
get-tar-commit-id.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
grep.c Merge branch 'jc/grep-f-relative-to-cwd' 2023-11-07 10:26:43 +09:00
hash-object.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
help.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
hook.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
index-pack.c Merge branch 'ew/hash-with-openssl-evp' 2023-09-13 10:07:57 -07:00
init-db.c builtin/init: introduce --ref-format= value flag 2024-01-02 09:24:48 -08:00
interpret-trailers.c Merge branch 'la/trailer-test-and-doc-updates' 2023-10-13 14:18:27 -07:00
log.c Merge branch 'jk/implicit-true' 2023-12-20 10:14:54 -08:00
ls-files.c Merge branch 'rs/strbuf-expand-step' 2023-07-06 11:54:45 -07:00
ls-remote.c ref-filter.c: really don't sort when using --no-sort 2023-11-16 14:02:58 +09:00
ls-tree.c ls-tree: mark unused parameter in callback 2023-08-29 17:56:24 -07:00
mailinfo.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
mailsplit.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-base.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-file.c merge-file: add --diff-algorithm option 2023-11-22 14:23:06 +09:00
merge-index.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
merge-ours.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
merge-recursive.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-tree.c i18n: factorize even more 'incompatible options' messages 2023-11-27 10:01:45 +09:00
merge.c Merge branch 'jk/commit-graph-leak-fixes' 2023-10-13 14:18:28 -07:00
mktag.c fsck: mark unused parameters in various fsck callbacks 2023-07-13 17:24:00 -07:00
mktree.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
multi-pack-index.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
mv.c Merge branch 'jc/mv-d-to-d-error-message-fix' into maint-2.42 2023-11-02 16:53:22 +09:00
name-rev.c name-rev: use OPT_HIDDEN_BOOL for --peel-tag 2023-09-05 14:58:44 -07:00
notes.c Merge branch 'tl/notes-separator' 2023-07-06 11:54:47 -07:00
pack-objects.c config: handle NULL value when parsing non-bools 2023-12-09 08:24:39 +09:00
pack-redundant.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
pack-refs.c pack-refs: teach pack-refs --include option 2023-05-12 14:54:14 -07:00
patch-id.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
prune-packed.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
pull.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
push.c Merge branch 'jk/config-cleanup' 2023-12-20 10:14:55 -08:00
range-diff.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
read-tree.c parse-options: mark unused "opt" parameter in callbacks 2023-09-05 14:48:17 -07:00
rebase.c rebase: support --autosquash without -i 2023-11-16 09:18:22 +09:00
receive-pack.c fsck: handle NULL value when parsing message config 2023-12-09 08:24:47 +09:00
reflog.c Merge branch 'jb/reflog-expire-delete-dry-run-options' 2023-12-18 14:10:12 -08:00
remote-ext.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote-fd.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote.c Merge branch 'jc/parse-options-short-help' 2023-08-04 10:52:31 -07:00
repack.c repack: use die_for_incompatible_opt3() for -A/-k/--cruft 2023-12-09 07:39:12 +09:00
replace.c replace: mark unused parameter in each_mergetag_fn callback 2023-07-13 17:24:00 -07:00
replay.c replay: stop assuming replayed branches do not diverge 2023-11-26 10:10:50 +09:00
rerere.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
reset.c Merge branch 'jc/parse-options-reset' 2023-07-27 15:26:37 -07:00
rev-list.c rev-list: add commit object support in --missing option 2023-11-01 12:07:18 +09:00
rev-parse.c builtin/rev-parse: introduce --show-ref-format flag 2024-01-02 09:24:48 -08:00
revert.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
rm.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
send-pack.c push: drop confusing configset/callback redundancy 2023-12-09 08:26:22 +09:00
shortlog.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
show-branch.c Merge branch 'jc/parse-options-show-branch' 2023-07-27 15:26:37 -07:00
show-index.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
show-ref.c builtin/show-ref: add new mode to check for reference existence 2023-11-01 12:09:01 +09:00
sparse-checkout.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
stash.c Merge branch 'jc/fail-stash-to-store-non-stash' 2023-10-23 13:56:37 -07:00
stripspace.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
submodule--helper.c submodule--helper: return error from set-url when modifying failed 2023-10-03 15:30:43 -07:00
symbolic-ref.c git-compat-util: move strbuf.c funcs to its header 2023-07-05 11:41:18 -07:00
tag.c ref-filter.h: add functions for filter/format & format-only 2023-11-16 14:02:59 +09:00
unpack-file.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
unpack-objects.c Merge branch 'ew/hash-with-openssl-evp' 2023-09-13 10:07:57 -07:00
update-index.c Merge branch 'jc/unresolve-removal' 2023-10-02 11:20:00 -07:00
update-ref.c update-ref: mark unused parameter in parser callbacks 2023-08-29 17:56:26 -07:00
update-server-info.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
upload-archive.c repository: remove unnecessary include of path.h 2023-06-21 13:39:53 -07:00
upload-pack.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
var.c Merge branch 'bc/more-git-var' into maint-2.42 2023-11-02 16:53:23 +09:00
verify-commit.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
verify-pack.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
verify-tag.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
worktree.c builtin/worktree: create refdb via ref backend 2024-01-08 13:17:30 -08:00
write-tree.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00