feat(git): enable relative worktrees

This commit is contained in:
Michael Mandl 2025-04-11 10:26:22 +02:00
parent bb8ac5db06
commit 4f336803ab
Signed by: mandlm
GPG key ID: 088ED38F036C7AF2

View file

@ -105,7 +105,10 @@
tag.sort = "version:refname";
worktree.guessRemote = true;
worktree = {
guessRemote = true;
useRelativePaths = true;
};
};
aliases = {
@ -144,26 +147,5 @@
git -C ''${dir}/.base checkout --detach HEAD
git -C ''${dir}/.base worktree add ../''${branch}
'')
(writeShellScriptBin "git-make-relative" ''
gitfile=''${1}
if [[ -z ''${gitfile} ]]; then
gitfile=".git"
fi
if [[ ! -f ''${gitfile} ]]; then
echo "file ''${gitfile} does not exist"
exit 1
fi
gitdir=$(grep "gitdir:" ''${gitfile} | cut -d: -f2 | xargs)
rel_gitdir=$(realpath -s --relative-to=. ''${gitdir})
echo "relative path: ''${rel_gitdir}"
sed -i -e "s,gitdir:.*,gitdir: ''${rel_gitdir}," ''${gitfile}
'')
];
}