@@ -415,7 +415,7 @@ scmTag() {
415415 return
416416 }
417417 done
418- error " $1 : inscrutable tag scheme"
418+ error " $1 : inscrutable tag scheme -- using default branch "
419419 else
420420 echo " $tag "
421421 fi
@@ -441,24 +441,43 @@ resolveSource() {
441441 # Check whether the needed branch/tag exists.
442442 local scmBranch
443443 test " $2 " && scmBranch=" $2 " || scmBranch=" $( scmTag " $1 " ) "
444- test " $scmBranch " || die " $1 : cannot glean SCM tag" 14
445- debug " git ls-remote \" file://$cachedRepoDir \" | grep -q \" \brefs/tags/$scmBranch $\" "
446- git ls-remote " file://$cachedRepoDir " | grep -q " \brefs/tags/$scmBranch $" || {
447- # Couldn't find the scmBranch as a tag in the cached repo. Either the
448- # tag is new, or it's not a tag ref at all (e.g. it's a branch).
449- # So let's update from the original remote repository.
450- info " $1 : local tag not found for ref '$scmBranch '"
444+
445+ if [ " $scmBranch " ]
446+ then
447+ # Successfully gleaned SCM branch/tag.
448+ debug " git ls-remote \" file://$cachedRepoDir \" | grep -q \" \brefs/tags/$scmBranch $\" "
449+ git ls-remote " file://$cachedRepoDir " | grep -q " \brefs/tags/$scmBranch $" || {
450+ # Couldn't find the scmBranch as a tag in the cached repo. Either the
451+ # tag is new, or it's not a tag ref at all (e.g. it's a branch).
452+ # So let's update from the original remote repository.
453+ info " $1 : local tag not found for ref '$scmBranch '"
454+ info " $1 : updating cached repository: $cachedRepoDir "
455+ cd " $cachedRepoDir "
456+ debug " git fetch --tags"
457+ if [ " $debug " ]
458+ then
459+ git fetch --tags
460+ else
461+ git fetch --tags > /dev/null
462+ fi
463+ cd - > /dev/null
464+ }
465+ else
466+ # No SCM branch/tag; fall back to the default branch.
451467 info " $1 : updating cached repository: $cachedRepoDir "
452468 cd " $cachedRepoDir "
453- debug " git fetch --tags "
469+ debug " git fetch"
454470 if [ " $debug " ]
455471 then
456- git fetch --tags
472+ git fetch
457473 else
458- git fetch --tags > /dev/null
474+ git fetch > /dev/null
459475 fi
476+ head=$( cat HEAD)
477+ scmBranch=${head##*/ }
478+ info " $1 : detected default branch as $scmBranch "
460479 cd - > /dev/null
461- }
480+ fi
462481
463482 # Shallow clone the source at the given version into melting-pot structure.
464483 local destDir=" $g /$a "
0 commit comments