Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas De Schampheleire <patrickdepinguin@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 08/11] support/download: implement source-check in git backend
Date: Thu,  3 Jan 2019 21:40:23 +0100	[thread overview]
Message-ID: <20190103204026.23512-9-patrickdepinguin@gmail.com> (raw)
In-Reply-To: <20190103204026.23512-1-patrickdepinguin@gmail.com>

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The implementation is the same as originally was present.
It suffers from the disadvantage that an invalid revision on a valid URL
will not be detected.

However, git does not seem to allow a good way to remotely check the
validity of a revision, without cloning the repository.

For source-check, we don't want to do such download which can be large.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/git | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/support/download/git b/support/download/git
index 17ca04eb98..54f3494c61 100755
--- a/support/download/git
+++ b/support/download/git
@@ -7,6 +7,7 @@ set -E
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the changeset exists in the remote repository
 #   -r          Clone and archive sub-modules.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Clone from repository at URI.
@@ -48,6 +49,7 @@ recurse=0
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=-q; exec >/dev/null;;
+    C)  checkonly=1;;
     r)  recurse=1;;
     o)  output="${OPTARG}";;
     u)  uri="${OPTARG}";;
@@ -61,6 +63,20 @@ done
 
 shift $((OPTIND-1)) # Get rid of our options
 
+# Caller needs to single-quote its arguments to prevent them from
+# being expanded a second time (in case there are spaces in them)
+_git() {
+    eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
+}
+
+if [ -n "${checkonly}" ]; then
+    # TODO this check only checks that the remote repository exists, not that
+    # it actually contains the requested revision. And for checkonly, we want
+    # to avoid creating a clone first.
+    _git ls-remote --heads "${@}" "'${uri}'" > /dev/null
+    exit ${?}
+fi
+
 # Create and cd into the directory that will contain the local git cache
 git_cache="${dl_dir}/git"
 mkdir -p "${git_cache}"
@@ -69,12 +85,6 @@ pushd "${git_cache}" >/dev/null
 # Any error now should try to recover
 trap _on_error ERR
 
-# Caller needs to single-quote its arguments to prevent them from
-# being expanded a second time (in case there are spaces in them)
-_git() {
-    eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
-}
-
 # Create a warning file, that the user should not use the git cache.
 # It's ours. Our precious.
 cat <<-_EOF_ >"${dl_dir}/git.readme"
-- 
2.18.1

  parent reply	other threads:[~2019-01-03 20:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03 20:40 [Buildroot] [PATCH 00/11] support/download: fix scp and reintroduce source-check Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 01/11] support/download: fix scp downloads Thomas De Schampheleire
2019-01-03 20:55   ` Yann E. MORIN
2019-01-03 21:03     ` Thomas De Schampheleire
2019-01-03 21:26       ` Yann E. MORIN
2019-01-03 21:07   ` Thomas Petazzoni
2019-01-24 10:47   ` Peter Korsgaard
2019-01-03 20:40 ` [Buildroot] [PATCH 02/11] support/download: fix scp download with scheme prefix 'scp://' Thomas De Schampheleire
2019-01-03 21:32   ` Yann E. MORIN
2019-01-03 20:40 ` [Buildroot] [PATCH 03/11] support/download: reintroduce 'source-check' target Thomas De Schampheleire
2019-01-03 21:17   ` Yann E. MORIN
2019-01-03 21:41     ` Peter Korsgaard
2019-01-04  9:07       ` Thomas De Schampheleire
2019-01-08 12:11         ` Thomas De Schampheleire
2019-01-15 10:59           ` Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 04/11] support/download: implement source-check in hg backend Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 05/11] support/download: implement source-check in wget backend Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 06/11] support/download: implement source-check in file backend Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 07/11] support/download: implement source-check in scp backend Thomas De Schampheleire
2019-01-03 20:40 ` Thomas De Schampheleire [this message]
2019-01-03 20:59   ` [Buildroot] [PATCH 08/11] support/download: implement source-check in git backend Thomas Petazzoni
2019-01-03 22:18     ` Yann E. MORIN
2019-01-08 12:12     ` Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 09/11] support/download: implement source-check in bzr backend Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 10/11] support/download: implement source-check in cvs backend Thomas De Schampheleire
2019-01-03 20:40 ` [Buildroot] [PATCH 11/11] support/download: implement source-check in svn backend Thomas De Schampheleire
2019-01-03 20:46 ` [Buildroot] [PATCH 00/11] support/download: fix scp and reintroduce source-check Thomas Petazzoni
2019-01-03 20:54   ` Thomas De Schampheleire
2019-01-03 20:57     ` Thomas Petazzoni
2019-01-28  2:25       ` Ricardo Martincoski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190103204026.23512-9-patrickdepinguin@gmail.com \
    --to=patrickdepinguin@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox