]> Savannah Git Hosting - gnulib.git/commitdiff
gitsub.sh: For a submodule, merge from the right remote branch.
authorBruno Haible <bruno@clisp.org>
Fri, 16 Aug 2024 20:07:19 +0000 (22:07 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 17 Sep 2024 12:30:48 +0000 (14:30 +0200)
Reported by Marc Nieper-Wißkirchen <marc.nieper+gnu@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gnulib/2024-08/msg00101.html>.

* 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.

ChangeLog
top/gitsub.sh

index 4cd5080aacf919ce0a82e5f7dbd938759016ffb0..216458469f45fd9dd891cc826ec182b7b9205a94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-08-16  Bruno Haible  <bruno@clisp.org>
+
+       gitsub.sh: For a submodule, merge from the right remote branch.
+       Reported by Marc Nieper-Wißkirchen <marc.nieper+gnu@gmail.com> at
+       <https://lists.gnu.org/archive/html/bug-gnulib/2024-08/msg00101.html>.
+       * 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  <bruno@clisp.org>
 
        tests: Fix link errors (regression 2024-08-12).
index 93cc2fb9193ef7eec55d129e74fa0465ee8d6d0c..38b15a4e24b50de5f4f2f0d7ab47e878e988b124 100755 (executable)
@@ -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