summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2017-06-29 05:19:33 (GMT)
committerAlexey Neyman <stilor@att.net>2017-07-08 17:57:56 (GMT)
commitc7a924a0732bd2aefe9af1411da629ccc3f34811 (patch)
treed65e21574b33c2f51f4b446651d721aa0e0894ba /scripts/functions
parentf672e3df8973d87b5542ee3f30d1b9ceacab6dca (diff)
Fix printing the branch used in Git
... and prefer exact specified name, if it exists. More bootstrap script specifications for packages. Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions19
1 files changed, 17 insertions, 2 deletions
diff --git a/scripts/functions b/scripts/functions
index 719c385..24cc667 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -1629,6 +1629,7 @@ CT_GetVersion_git()
if [ -z "${devel_revision}" ]; then
local matches=`git ls-remote --exit-code "${devel_url}" --refs "${devel_branch}" \
|| echo "not found"`
+ local best using ref
# Cannot test $?, setting a trap on ERR prevents bash from returning the
# status code.
@@ -1636,9 +1637,22 @@ CT_GetVersion_git()
CT_Abort "Failed to find git ref ${devel_branch} at ${devel_url}"
fi
if [ `echo "${matches}" | wc -l` -gt 1 ]; then
- CT_DoLog WARN "Ambiguous ref ${devel_branch} at ${devel_url}, using first"
+ if echo "${matches}" | grep '[[:space:]]\(refs/heads/\)\?'"${devel_branch}\$" >/dev/null; then
+ # Try exact match, or prepended with "refs/heads". Some projects (e.g. binutils)
+ # have refs/original/refs/heads/master as well as refs/heads/master, and
+ # `git ls-remote refs/heads/master` prints both.
+ best=`echo "${matches}" | grep '[[:space:]]\(refs/heads/\)\?'"${devel_branch}\$"`
+ using="best match"
+ else
+ best=`echo "${matches}" | head -n1`
+ using="first"
+ fi
+ ref=`echo "${best}" | sed 's/.*[[:space:]]//'`
+ CT_DoLog WARN "Ambiguous ref ${devel_branch} at ${devel_url}, using ${using} (${ref})"
+ else
+ best="${matches}"
fi
- devel_revision=`echo "$matches" | head -n1 | cut -c1-8`
+ devel_revision=`echo "${best}" | cut -c1-8`
CT_DoLog DEBUG "ref ${devel_branch} at ${devel_url} has cset of ${devel_revision}"
fi
basename="${pkg_name}-${devel_revision}"
@@ -1647,6 +1661,7 @@ CT_GetVersion_git()
# Retrieve sources from Git.
CT_Download_git()
{
+ # Git does not allow making a shallow clone of a specific commit.
CT_DoExecLog ALL git clone "${devel_url}" "${pkg_name}"
CT_Pushd "${pkg_name}"
CT_DoExecLog ALL git checkout "${devel_revision}" --