From cecb7202b6060695319949d792b1981c5c52d845 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 2 Jan 2025 08:26:50 +0100 Subject: Adding support for external git directory for repositories in git-repo-repack. Signed-off-by: Daniel Baumann --- git/bin/git-repo-repack | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/git/bin/git-repo-repack b/git/bin/git-repo-repack index f78f40b..726c6a6 100755 --- a/git/bin/git-repo-repack +++ b/git/bin/git-repo-repack @@ -35,12 +35,31 @@ REPOSITORIES="${*}" if [ -z "${REPOSITORIES}" ] then - if [ ! -e HEAD ] + # repository with git directory + if [ -e .git ] && [ ! -d .git ] then - REPOSITORIES="*.git" - else - REPOSITORIES="$(pwd)" + REPOSITORIES="$(awk -Fgitdir:\ '{ print $2 }' .git)" fi + + if [ ! -d "${REPOSITORIES}" ] + then + if [ ! -e HEAD ] + then + if [ -d .git ] + then + REPOSITORIES="$(pwd)/.git" + fi + else + # bare repository + REPOSITORIES="$(pwd)" + fi + fi +fi + +if [ -z "${REPOSITORIES}" ] +then + echo "current directory is not a git repository, doing nothing." + exit 1 fi for REPOSITORY in ${REPOSITORIES} -- cgit v1.2.3