Fix setting branch on submodules

This commit is contained in:
Daniel Berteaud 2024-01-11 15:50:21 +01:00
parent 63d8785da5
commit 34a00e5576
1 changed files with 6 additions and 1 deletions

7
ctctl
View File

@ -475,7 +475,12 @@ ctctl_add_submodule(){
git submodule add --branch ${BRANCH} --name ${MODULE} --force ${URL} ${DIR}/${NAME}
else
echo "Updating ${MODULE} submodule from ${URL} (branch ${BRANCH})"
git submodule set-branch --branch ${BRANCH} ${DIR}/${NAME}
# Get the git top-level, then compare with $(pwd) to get the correct relative path of the bundle,
# from the git parent root point of view (not from $(pwd))
local GIT_ROOT=$(git rev-parse --show-toplevel)
local CURRENT_DIR=$(pwd)
local MODULE_REL_DIR=$(echo ${CURRENT_DIR} | sed -E "s|^${GIT_ROOT}/||")
git submodule set-branch --branch ${BRANCH} -- ${MODULE_REL_DIR}/${DIR}/${NAME}
fi
git submodule update --init --recursive --remote --merge ${DIR}/${NAME}
}