aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorCaleb White <cdwhite3@pm.me>2024-11-29 22:23:10 +0000
committerJunio C Hamano <gitster@pobox.com>2024-12-02 09:36:17 +0900
commite6df1ee2c13405ef7077256fef49424f69d61125 (patch)
tree3e514475befc6fac0a354870d244e04cf25f0a6d /builtin
parentworktree: add relative cli/config options to `move` command (diff)
downloadgit-e6df1ee2c13405ef7077256fef49424f69d61125.tar.gz
git-e6df1ee2c13405ef7077256fef49424f69d61125.zip
worktree: add relative cli/config options to `repair` command
This teaches the `worktree repair` command to respect the `--[no-]relative-paths` CLI option and `worktree.useRelativePaths` config setting. If an existing worktree with an absolute path is repaired with `--relative-paths`, the links will be replaced with relative paths, even if the original path was correct. This allows a user to covert existing worktrees between absolute/relative as desired. To simplify things, both linking files are written when one of the files needs to be repaired. In some cases, this fixes the other file before it is checked, in other cases this results in a correct file being written with the same contents. Signed-off-by: Caleb White <cdwhite3@pm.me> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/worktree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 3021515069..fde9ff4dc9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1385,6 +1385,8 @@ static int repair(int ac, const char **av, const char *prefix)
const char **p;
const char *self[] = { ".", NULL };
struct option options[] = {
+ OPT_BOOL(0, "relative-paths", &use_relative_paths,
+ N_("use relative paths for worktrees")),
OPT_END()
};
int rc = 0;
@@ -1392,8 +1394,8 @@ static int repair(int ac, const char **av, const char *prefix)
ac = parse_options(ac, av, prefix, options, git_worktree_repair_usage, 0);
p = ac > 0 ? av : self;
for (; *p; p++)
- repair_worktree_at_path(*p, report_repair, &rc);
- repair_worktrees(report_repair, &rc);
+ repair_worktree_at_path(*p, report_repair, &rc, use_relative_paths);
+ repair_worktrees(report_repair, &rc, use_relative_paths);
return rc;
}