commit 60dfa2dd3b490a78e8f6a58a2421f3475c128caf parent b6b05245b436e976038f5b1c9156e2d0d2edfabf Author: Jan Pobrislo <ccx@te2000.cz> Date: Tue, 18 Mar 2025 23:28:47 +0000 Add subbranch script Diffstat:
A | submodules-update-branch | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/submodules-update-branch b/submodules-update-branch @@ -0,0 +1,43 @@ +#!/bin/sh -e +prog=$(basename "$0") +fatal() { + printf >&2 '%s: fatal: %s\n' "$prog" "$*" + exit 1 +} +cd "$(dirname "$0")" +prefix=mrrl- +branch=$(git branch --show-current --format '%(refname:short)') +branch=trunk +if test -z "$branch"; then + fatal "could not determine branch name" +fi +git submodule status --cached --recursive | while read -r line; do + line=${line# } + commit=${line%% *} + line=${line#* } + submodule=${line%% (*} + if test -z "$submodule"; then + fatal "could not determine submodule name" + fi + case "$commit" in + ("") + fatal "could not determine commit id" + ;; + (-*) + # not checked out, skip + continue + ;; + (+*) + fatal "submodule '$submodule' has different than recorded commit id" + ;; + ([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]) + ;; + (*) + fatal "invalid commit id" + ;; + esac + case "$line" in + (*' (heads/mrrl-trunk)') continue;; + esac + ( cd $submodule && if test x"$(git branch --show-current)" = x"$prefix$branch"; then git merge --ff-only "$commit"; else git branch --force "$prefix$branch" "$commit"; fi ) +done