From: Bruno Haible Date: Fri, 16 Aug 2024 20:07:19 +0000 (+0200) Subject: gitsub.sh: For a submodule, merge from the right remote branch. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cd4a88cc81afa9e2d830ad6105df1de7539a4889;p=gnulib.git gitsub.sh: For a submodule, merge from the right remote branch. Reported by Marc Nieper-Wißkirchen at . * top/gitsub.sh (func_upgrade): For a submodule, use 'git branch' to determine the branch to merge from, instead of assuming that it is always the 'master' branch. --- diff --git a/ChangeLog b/ChangeLog index 4cd5080aac..216458469f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-08-16 Bruno Haible + + gitsub.sh: For a submodule, merge from the right remote branch. + Reported by Marc Nieper-Wißkirchen at + . + * top/gitsub.sh (func_upgrade): For a submodule, use 'git branch' to + determine the branch to merge from, instead of assuming that it is + always the 'master' branch. + 2024-08-14 Bruno Haible tests: Fix link errors (regression 2024-08-12). diff --git a/top/gitsub.sh b/top/gitsub.sh index 93cc2fb919..38b15a4e24 100755 --- a/top/gitsub.sh +++ b/top/gitsub.sh @@ -392,7 +392,17 @@ func_upgrade () case " $submodule_names " in *" $1 "*) # It's a submodule. if test -z "$needs_init"; then - (cd "$path" && git fetch && git merge origin/master) || func_fatal_error "git operation failed" + (cd "$path" \ + && git fetch \ + && branch=`git branch --show-current` \ + && { test -n "$branch" || branch=HEAD; } \ + && sed_escape_dots='s/\([.]\)/\\\1/g' \ + && branch_escaped=`echo "$branch" | sed -e "${sed_escape_dots}"` \ + && remote=`git branch -r | sed -n -e "s| origin/${branch_escaped} -> ||p"` \ + && { test -n "$remote" || remote="origin/${branch}"; } \ + && echo "In subdirectory $path: Running \"git merge $remote\"" \ + && git merge "$remote" + ) || func_fatal_error "git operation failed" fi ;; esac