]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Don't fetch remote if the commit to check out already exists
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 29 Aug 2024 16:36:55 +0000 (18:36 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 29 Aug 2024 18:16:19 +0000 (19:16 +0100)
If the commit we're about to check out already exists in the local
repository, don't fetch from the remote repository.

mkosi.images/build/mkosi.sync

index febe893c41f3f8d6d4cea537fd34043a9199fd21..4cb2b41a4e2c8ce503ba404a36d67f50b84c4f34 100755 (executable)
@@ -43,7 +43,7 @@ if [[ ! -e "pkg/$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "pkg/$PKG_SUBDIR")"
         # --no-cone is needed to check out only one top-level directory
         git -C "pkg/$PKG_SUBDIR" sparse-checkout set --no-cone "${GIT_SUBDIR:-}"
     fi
-else
+elif ! git -C "pkg/$PKG_SUBDIR" cat-file -e "$GIT_COMMIT^{commit}"; then
     git -C "pkg/$PKG_SUBDIR" remote set-url origin "$GIT_URL"
     git -C "pkg/$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
 fi