worktree: add relativeWorktrees
extension
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d897f2c16d
commit
1860ba1a2a
@ -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
|
linkgit:git-clone[1]. Trying to change it after initialization will not
|
||||||
work and will produce hard-to-diagnose issues.
|
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::
|
worktreeConfig::
|
||||||
If enabled, then worktrees will load config settings from the
|
If enabled, then worktrees will load config settings from the
|
||||||
`$GIT_DIR/config.worktree` file in addition to the
|
`$GIT_DIR/config.worktree` file in addition to the
|
||||||
|
@ -283,6 +283,7 @@ int repo_init(struct repository *repo,
|
|||||||
repo_set_compat_hash_algo(repo, format.compat_hash_algo);
|
repo_set_compat_hash_algo(repo, format.compat_hash_algo);
|
||||||
repo_set_ref_storage_format(repo, format.ref_storage_format);
|
repo_set_ref_storage_format(repo, format.ref_storage_format);
|
||||||
repo->repository_format_worktree_config = format.worktree_config;
|
repo->repository_format_worktree_config = format.worktree_config;
|
||||||
|
repo->repository_format_relative_worktrees = format.relative_worktrees;
|
||||||
|
|
||||||
/* take ownership of format.partial_clone */
|
/* take ownership of format.partial_clone */
|
||||||
repo->repository_format_partial_clone = format.partial_clone;
|
repo->repository_format_partial_clone = format.partial_clone;
|
||||||
|
@ -150,6 +150,7 @@ struct repository {
|
|||||||
|
|
||||||
/* Configurations */
|
/* Configurations */
|
||||||
int repository_format_worktree_config;
|
int repository_format_worktree_config;
|
||||||
|
int repository_format_relative_worktrees;
|
||||||
|
|
||||||
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
|
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
|
||||||
unsigned different_commondir:1;
|
unsigned different_commondir:1;
|
||||||
|
7
setup.c
7
setup.c
@ -683,6 +683,9 @@ static enum extension_result handle_extension(const char *var,
|
|||||||
"extensions.refstorage", value);
|
"extensions.refstorage", value);
|
||||||
data->ref_storage_format = format;
|
data->ref_storage_format = format;
|
||||||
return EXTENSION_OK;
|
return EXTENSION_OK;
|
||||||
|
} else if (!strcmp(ext, "relativeworktrees")) {
|
||||||
|
data->relative_worktrees = git_config_bool(var, value);
|
||||||
|
return EXTENSION_OK;
|
||||||
}
|
}
|
||||||
return EXTENSION_UNKNOWN;
|
return EXTENSION_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -1854,6 +1857,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
|
|||||||
repo_fmt.ref_storage_format);
|
repo_fmt.ref_storage_format);
|
||||||
the_repository->repository_format_worktree_config =
|
the_repository->repository_format_worktree_config =
|
||||||
repo_fmt.worktree_config;
|
repo_fmt.worktree_config;
|
||||||
|
the_repository->repository_format_relative_worktrees =
|
||||||
|
repo_fmt.relative_worktrees;
|
||||||
/* take ownership of repo_fmt.partial_clone */
|
/* take ownership of repo_fmt.partial_clone */
|
||||||
the_repository->repository_format_partial_clone =
|
the_repository->repository_format_partial_clone =
|
||||||
repo_fmt.partial_clone;
|
repo_fmt.partial_clone;
|
||||||
@ -1950,6 +1955,8 @@ void check_repository_format(struct repository_format *fmt)
|
|||||||
fmt->ref_storage_format);
|
fmt->ref_storage_format);
|
||||||
the_repository->repository_format_worktree_config =
|
the_repository->repository_format_worktree_config =
|
||||||
fmt->worktree_config;
|
fmt->worktree_config;
|
||||||
|
the_repository->repository_format_relative_worktrees =
|
||||||
|
fmt->relative_worktrees;
|
||||||
the_repository->repository_format_partial_clone =
|
the_repository->repository_format_partial_clone =
|
||||||
xstrdup_or_null(fmt->partial_clone);
|
xstrdup_or_null(fmt->partial_clone);
|
||||||
clear_repository_format(&repo_fmt);
|
clear_repository_format(&repo_fmt);
|
||||||
|
1
setup.h
1
setup.h
@ -129,6 +129,7 @@ struct repository_format {
|
|||||||
int precious_objects;
|
int precious_objects;
|
||||||
char *partial_clone; /* value of extensions.partialclone */
|
char *partial_clone; /* value of extensions.partialclone */
|
||||||
int worktree_config;
|
int worktree_config;
|
||||||
|
int relative_worktrees;
|
||||||
int is_bare;
|
int is_bare;
|
||||||
int hash_algo;
|
int hash_algo;
|
||||||
int compat_hash_algo;
|
int compat_hash_algo;
|
||||||
|
Reference in New Issue
Block a user