@@ -415,7 +415,7 @@ scmTag() {
415
415
return
416
416
}
417
417
done
418
- error " $1 : inscrutable tag scheme"
418
+ error " $1 : inscrutable tag scheme -- using default branch "
419
419
else
420
420
echo " $tag "
421
421
fi
@@ -441,24 +441,43 @@ resolveSource() {
441
441
# Check whether the needed branch/tag exists.
442
442
local scmBranch
443
443
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.
451
467
info " $1 : updating cached repository: $cachedRepoDir "
452
468
cd " $cachedRepoDir "
453
- debug " git fetch --tags "
469
+ debug " git fetch"
454
470
if [ " $debug " ]
455
471
then
456
- git fetch --tags
472
+ git fetch
457
473
else
458
- git fetch --tags > /dev/null
474
+ git fetch > /dev/null
459
475
fi
476
+ head=$( cat HEAD)
477
+ scmBranch=${head##*/ }
478
+ info " $1 : detected default branch as $scmBranch "
460
479
cd - > /dev/null
461
- }
480
+ fi
462
481
463
482
# Shallow clone the source at the given version into melting-pot structure.
464
483
local destDir=" $g /$a "
0 commit comments