From: Caleb White <cdwhite3@pm.me>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>,
Phillip Wood <phillip.wood123@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Caleb White <cdwhite3@pm.me>
Subject: [PATCH v5 2/8] worktree: add `relativeWorktrees` extension
Date: Tue, 26 Nov 2024 01:51:44 +0000 [thread overview]
Message-ID: <20241125-wt_relative_options-v5-2-356d122ff3db@pm.me> (raw)
In-Reply-To: <20241125-wt_relative_options-v5-0-356d122ff3db@pm.me>
A new extension, `relativeWorktrees`, is added to indicate that at least
one worktree in the repository has been linked with relative paths.
This ensures older Git versions do not attempt to automatically prune
worktrees with relative paths, as they would not not recognize the
paths as being valid.
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Caleb White <cdwhite3@pm.me>
---
Documentation/config/extensions.txt | 6 ++++++
repository.c | 1 +
repository.h | 1 +
setup.c | 7 +++++++
setup.h | 1 +
5 files changed, 16 insertions(+)
diff --git a/Documentation/config/extensions.txt b/Documentation/config/extensions.txt
index 5dc569d1c9c77c15e32441493289f9c9dd5e7f0b..5cb4721a0e0ae1ed64f90492c0dc18b96473cb33 100644
--- a/Documentation/config/extensions.txt
+++ b/Documentation/config/extensions.txt
@@ -63,6 +63,12 @@ Note that this setting should only be set by linkgit:git-init[1] or
linkgit:git-clone[1]. Trying to change it after initialization will not
work and will produce hard-to-diagnose issues.
+relativeWorktrees::
+ If enabled, indicates at least one worktree has been linked with
+ relative paths. Automatically set if a worktree has been created or
+ repaired with either the `--relative-paths` option or with the
+ `worktree.useRelativePaths` config set to `true`.
+
worktreeConfig::
If enabled, then worktrees will load config settings from the
`$GIT_DIR/config.worktree` file in addition to the
diff --git a/repository.c b/repository.c
index f988b8ae68a6a29792e7f2c980a02bd0e388a3b9..1a6a62bbd03a5dc4fdade3eb45ea2696968abc23 100644
--- a/repository.c
+++ b/repository.c
@@ -283,6 +283,7 @@ int repo_init(struct repository *repo,
repo_set_compat_hash_algo(repo, format.compat_hash_algo);
repo_set_ref_storage_format(repo, format.ref_storage_format);
repo->repository_format_worktree_config = format.worktree_config;
+ repo->repository_format_relative_worktrees = format.relative_worktrees;
/* take ownership of format.partial_clone */
repo->repository_format_partial_clone = format.partial_clone;
diff --git a/repository.h b/repository.h
index 24a66a496a6ff516ce06d47b7329b3d36eb701ca..c4c92b2ab9c9e3b425dc2974636e33d1f4089c69 100644
--- a/repository.h
+++ b/repository.h
@@ -150,6 +150,7 @@ struct repository {
/* Configurations */
int repository_format_worktree_config;
+ int repository_format_relative_worktrees;
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
unsigned different_commondir:1;
diff --git a/setup.c b/setup.c
index 1e5c2eacb19eb6b230d7c9954f66fc7ae0b05631..39ff48d9dc5d67b16159c6cca66ff2663bbba6cf 100644
--- a/setup.c
+++ b/setup.c
@@ -683,6 +683,9 @@ static enum extension_result handle_extension(const char *var,
"extensions.refstorage", value);
data->ref_storage_format = format;
return EXTENSION_OK;
+ } else if (!strcmp(ext, "relativeworktrees")) {
+ data->relative_worktrees = git_config_bool(var, value);
+ return EXTENSION_OK;
}
return EXTENSION_UNKNOWN;
}
@@ -1854,6 +1857,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
repo_fmt.ref_storage_format);
the_repository->repository_format_worktree_config =
repo_fmt.worktree_config;
+ the_repository->repository_format_relative_worktrees =
+ repo_fmt.relative_worktrees;
/* take ownership of repo_fmt.partial_clone */
the_repository->repository_format_partial_clone =
repo_fmt.partial_clone;
@@ -1950,6 +1955,8 @@ void check_repository_format(struct repository_format *fmt)
fmt->ref_storage_format);
the_repository->repository_format_worktree_config =
fmt->worktree_config;
+ the_repository->repository_format_relative_worktrees =
+ fmt->relative_worktrees;
the_repository->repository_format_partial_clone =
xstrdup_or_null(fmt->partial_clone);
clear_repository_format(&repo_fmt);
diff --git a/setup.h b/setup.h
index e496ab3e4de580c2d9f95a7ea0eaf90e0d41b070..18dc3b73686ce28fac2fe04282ce95f8bf3e6b74 100644
--- a/setup.h
+++ b/setup.h
@@ -129,6 +129,7 @@ struct repository_format {
int precious_objects;
char *partial_clone; /* value of extensions.partialclone */
int worktree_config;
+ int relative_worktrees;
int is_bare;
int hash_algo;
int compat_hash_algo;
--
2.47.0
next prev parent reply other threads:[~2024-11-26 1:51 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 4:38 [PATCH v4 0/8] Allow relative worktree linking to be configured by the user Caleb White
2024-11-01 4:38 ` [PATCH v4 1/8] setup: correctly reinitialize repository version Caleb White
2024-11-01 4:38 ` [PATCH v4 2/8] worktree: add `relativeWorktrees` extension Caleb White
2024-11-19 15:07 ` Phillip Wood
2024-11-20 5:13 ` Caleb White
2024-11-22 16:44 ` Phillip Wood
2024-11-22 19:27 ` Caleb White
2024-11-01 4:38 ` [PATCH v4 3/8] worktree: refactor infer_backlink return Caleb White
2024-11-19 15:08 ` Phillip Wood
2024-11-20 5:20 ` Caleb White
2024-11-22 16:44 ` Phillip Wood
2024-11-22 19:26 ` Caleb White
2024-11-01 4:38 ` [PATCH v4 4/8] worktree: add `write_worktree_linking_files()` function Caleb White
2024-11-01 4:38 ` [PATCH v4 5/8] worktree: add relative cli/config options to `add` command Caleb White
2024-11-19 15:07 ` Phillip Wood
2024-11-20 5:01 ` Caleb White
2024-11-22 16:44 ` phillip.wood123
2024-11-23 4:40 ` Caleb White
2024-11-01 4:38 ` [PATCH v4 6/8] worktree: add relative cli/config options to `move` command Caleb White
2024-11-22 15:55 ` Phillip Wood
2024-11-23 4:11 ` Caleb White
2024-11-01 4:38 ` [PATCH v4 7/8] worktree: add relative cli/config options to `repair` command Caleb White
2024-11-22 15:55 ` Phillip Wood
2024-11-23 5:41 ` Caleb White
2024-11-24 19:27 ` phillip.wood123
2024-11-26 0:00 ` Caleb White
2024-11-01 4:39 ` [PATCH v4 8/8] worktree: refactor `repair_worktree_after_gitdir_move()` Caleb White
2024-11-22 15:58 ` Phillip Wood
2024-11-23 4:36 ` Caleb White
2024-11-01 7:14 ` [PATCH v4 0/8] Allow relative worktree linking to be configured by the user Junio C Hamano
2024-11-01 13:18 ` Caleb White
2024-11-02 10:09 ` Junio C Hamano
2024-11-02 14:36 ` Kristoffer Haugsbakk
2024-11-22 15:57 ` Phillip Wood
2024-11-23 5:45 ` Caleb White
2024-11-26 1:51 ` [PATCH v5 " Caleb White
2024-11-26 1:51 ` [PATCH v5 1/8] setup: correctly reinitialize repository version Caleb White
2024-11-26 1:51 ` Caleb White [this message]
2024-11-26 1:51 ` [PATCH v5 3/8] worktree: refactor infer_backlink return Caleb White
2024-11-26 1:51 ` [PATCH v5 4/8] worktree: add `write_worktree_linking_files()` function Caleb White
2024-11-26 1:52 ` [PATCH v5 5/8] worktree: add relative cli/config options to `add` command Caleb White
2024-11-26 1:52 ` [PATCH v5 6/8] worktree: add relative cli/config options to `move` command Caleb White
2024-11-26 1:52 ` [PATCH v5 7/8] worktree: add relative cli/config options to `repair` command Caleb White
2024-11-26 1:52 ` [PATCH v5 8/8] worktree: refactor `repair_worktree_after_gitdir_move()` Caleb White
2024-11-26 6:18 ` [PATCH v5 0/8] Allow relative worktree linking to be configured by the user Junio C Hamano
2024-11-26 17:02 ` Caleb White
2024-11-28 14:44 ` Phillip Wood
2024-11-28 17:58 ` Caleb White
2024-11-29 22:22 ` [PATCH v6 " Caleb White
2024-11-29 22:22 ` [PATCH v6 1/8] setup: correctly reinitialize repository version Caleb White
2024-11-29 22:22 ` [PATCH v6 2/8] worktree: add `relativeWorktrees` extension Caleb White
2024-11-29 22:22 ` [PATCH v6 3/8] worktree: refactor infer_backlink return Caleb White
2024-11-29 22:22 ` [PATCH v6 4/8] worktree: add `write_worktree_linking_files()` function Caleb White
2024-11-29 22:22 ` [PATCH v6 5/8] worktree: add relative cli/config options to `add` command Caleb White
2024-11-29 22:23 ` [PATCH v6 6/8] worktree: add relative cli/config options to `move` command Caleb White
2024-11-29 22:23 ` [PATCH v6 7/8] worktree: add relative cli/config options to `repair` command Caleb White
2024-11-29 22:23 ` [PATCH v6 8/8] worktree: refactor `repair_worktree_after_gitdir_move()` Caleb White
2024-12-02 14:57 ` [PATCH v6 0/8] Allow relative worktree linking to be configured by the user Phillip Wood
2024-12-03 4:54 ` Junio C Hamano
2024-12-03 5:21 ` Caleb White
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125-wt_relative_options-v5-2-356d122ff3db@pm.me \
--to=cdwhite3@pm.me \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=phillip.wood123@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).