[openwrt/openwrt] scripts/feeds: shallow clone for specific commit update

LEDE Commits lede-commits at lists.infradead.org
Tue Mar 4 03:00:22 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/32d0a57dc10811a24816e51f10e55963f40fe462

commit 32d0a57dc10811a24816e51f10e55963f40fe462
Author: Cedric CHEDALEUX <cedric.chedaleux at orange.com>
AuthorDate: Mon Feb 17 10:41:32 2025 +0100

    scripts/feeds: shallow clone for specific commit update
    
    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 at orange.com>
    Link: https://github.com/openwrt/openwrt/pull/18003
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 scripts/feeds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/feeds b/scripts/feeds
index d07c28bc50..0ff6765814 100755
--- a/scripts/feeds
+++ b/scripts/feeds
@@ -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",




More information about the lede-commits mailing list