scripts/feeds: shallow clone for specific commit update
authorCedric CHEDALEUX <cedric.chedaleux@orange.com>
Mon, 17 Feb 2025 09:41:32 +0000 (10:41 +0100)
committerRobert Marko <robimarko@gmail.com>
Tue, 4 Mar 2025 11:00:19 +0000 (12:00 +0100)
When a feed is referenced with a specific commit (i.e. <git_url>^<sha1>),
a full clone was performed and a branch was created from the sha1
and named with the sha1. Other git clones operations are shallowed.

As Git does not support clone at a specific commit, let's first perform
a shallow clone to latest commit, then fetch the relevant commit and
finally checkout it (no more 'pseudo' branch).

It saves bandwith and significantly speeds up the feed update process.

Signed-off-by: Cedric CHEDALEUX <cedric.chedaleux@orange.com>
Link: https://github.com/openwrt/openwrt/pull/18003
Signed-off-by: Robert Marko <robimarko@gmail.com>
scripts/feeds

index d07c28bc50f8bd96b0a4146c8dfa7882de2d8fe8..0ff676581449640244f9ba1b4cce09328f0d80de 100755 (executable)
@@ -157,7 +157,7 @@ my %update_method = (
        'src-git' => {
                'init'          => "git clone --depth 1 '%s' '%s'",
                'init_branch'   => "git clone --depth 1 --branch '%s' '%s' '%s'",
-               'init_commit'   => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
+               'init_commit'   => "git clone --depth 1 '%s' '%s' && cd '%s' && git fetch --depth=1 origin '%s' && git -c advice.detachedHead=false checkout '%s' && cd -",
                'update'        => "git pull --ff-only",
                'update_rebase' => "git pull --rebase=merges",
                'update_stash'  => "git pull --rebase=merges --autostash",