sub upstream_commitish_search ($$) {
my ($upstream_version, $tried) = @_;
# todo: at some point maybe use git-deborig to do this
+ my @found;
foreach my $tagpfx ('', 'v', 'upstream/') {
my $tag = $tagpfx.(dep14_version_mangle $upstream_version);
my $new_upstream = git_get_ref "refs/tags/$tag";
push @$tried, $tag;
- return $new_upstream if length $new_upstream;
+ push @found, [ $tag, $new_upstream ] if $new_upstream;
}
+ return @{ $found[0] } if @found == 1;
+ return ();
}
sub resolve_upstream_version ($$) {
my $message = __ 'using specified upstream commitish';
if (!defined $new_upstream) {
my @tried;
- $new_upstream = upstream_commitish_search $upstream_version, \@tried;
+ ($used, $new_upstream) =
+ upstream_commitish_search $upstream_version, \@tried;
if (!length $new_upstream) {
fail f_
"Could not determine appropriate upstream commitish.\n".
" Check version, and specify upstream commitish explicitly.",
"@tried";
}
- $used = $tried[-1];
$message = f_ 'using upstream from git tag %s', $used;
} elsif ($new_upstream =~ m{^refs/tags/($versiontag_re)$}s) {
$message = f_ 'using upstream from git tag %s', $1;