]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Relax separate branch check in mkosi.sync
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Sep 2025 09:25:57 +0000 (11:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Sep 2025 10:11:48 +0000 (12:11 +0200)
There's no guarantee that $GIT_BRANCH is always the same across
stable release branches and main. But we still need to make sure
we switch commits if we're switching between main and release branches.

To make this work, let's not check if the current HEAD commit is an
ancestor of the currently configured origin branch. Instead, let's
check if any of the origin branches contains the current HEAD commit.
This still makes sure that we won't switch commits if we're working
on a local branch while making sure that we do switch commits if we're
switching between main and stable release branches with different
git branches configured for the packaging repo checkout.

mkosi/mkosi.sync

index 200695155b00b1342b616329544c40545e143a2c..82c575a2fc9b10d18190210e14334beadd313fd0 100755 (executable)
@@ -23,14 +23,9 @@ if [[ -d "pkg/$PKG_SUBDIR/.git" ]]; then
     fi
 
     # If work is being done on the packaging rules in a separate branch, don't touch the checkout.
-    if ! git -C "pkg/$PKG_SUBDIR" merge-base --is-ancestor HEAD "origin/$GIT_BRANCH"; then
-        EXIT_STATUS=$?
-        if [[ $EXIT_STATUS -eq 1 ]]; then
-            echo "Currently checked out pkg/$PKG_SUBDIR commit is not an ancestor of origin/$GIT_BRANCH, not checking out commit $GIT_COMMIT" >&2
-            exit 0
-        else
-            exit $EXIT_STATUS
-        fi
+    if [[ -z "$(git -C "pkg/$PKG_SUBDIR" branch --remotes --list "origin/*" --contains HEAD)" ]]; then
+        echo "Currently checked out pkg/$PKG_SUBDIR commit is not part of any origin branch, not checking out commit $GIT_COMMIT" >&2
+        exit 0
     fi
 fi