From 3563a5f1e23a8a174bd6faab26460a5ed14fd481 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Wed, 11 Jan 2023 15:22:39 +0100 Subject: [PATCH] armbian-next: curb down `git fetch` logging; be verbose if user on terminal & not logging --- lib/functions/general/git.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/functions/general/git.sh b/lib/functions/general/git.sh index d7b612fb2d..fad39a67b7 100644 --- a/lib/functions/general/git.sh +++ b/lib/functions/general/git.sh @@ -25,8 +25,9 @@ regular_git() { # avoid repeating myself too much function improved_git_fetch() { + declare -a verbose_params=() && if_user_on_terminal_and_not_logging_add verbose_params "--verbose" "--progress" # --no-auto-maintenance requires a recent git version, not available on focal-like host OSs - improved_git fetch --progress --verbose --recurse-submodules=no "$@" + improved_git fetch "${verbose_params[@]}" --recurse-submodules=no "$@" } # workaround new limitations imposed by CVE-2022-24765 fix in git, otherwise "fatal: unsafe repository" @@ -133,7 +134,7 @@ fetch_from_repo() { # Dir is not a git working copy. Make it so; display_alert "Initializing empty git local copy" "git init: $dir $ref_name" regular_git init -q . # --initial-branch="armbian_unused_initial_branch" is not supported under focal - offline=false # Force online, we'll need to fetch. + offline=false # Force online, we'll need to fetch. fi fi @@ -187,9 +188,20 @@ fetch_from_repo() { # remote was updated, fetch and check out updates, but not tags; tags pull their respective commits too, making it a huge fetch. display_alert "Fetching updates from remote repository" "$dir $ref_name" case $ref_type in - branch | commit) improved_git_fetch --no-tags "${url}" "${ref_name}" ;; - tag) improved_git_fetch --no-tags "${url}" tags/"${ref_name}" ;; - head) improved_git_fetch --no-tags "${url}" HEAD ;; + branch) + improved_git_fetch --no-tags "${url}" "${ref_name}" + ;; + commit) + # @TODO: if the local copy has the revision, skip the fetch -- would save us a lot of time + display_alert "Fetching a specific commit/sha1" "${ref_name}" "warn" + improved_git_fetch --no-tags "${url}" "${ref_name}" + ;; + tag) + improved_git_fetch --no-tags "${url}" tags/"${ref_name}" + ;; + head) + improved_git_fetch --no-tags "${url}" HEAD + ;; esac checkout_from="FETCH_HEAD" fi