chiark / gitweb /
git-debrebase: Break out resolve_upstream_version
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Aug 2018 06:39:11 +0000 (07:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Aug 2018 06:39:11 +0000 (07:39 +0100)
NFC.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index a28b910..35284d5 100755 (executable)
@@ -1184,18 +1184,23 @@ sub do_stitch ($;$) {
     stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
 }
 
+sub upstream_commitish_search ($$) {
+    my ($upstream_version, $tried) = @_;
+    # todo: at some point maybe use git-deborig to do this
+    foreach my $tagpfx ('', 'v', 'upstream/') {
+       my $tag = $tagpfx.(dep14_version_mangle $upstream_version);
+       my $new_upstream = git_get_ref "refs/tags/$tag";
+       return $new_upstream if length $new_upstream;
+       push @$tried, $tag;
+    }
+}
+
 sub resolve_upstream_version ($$) {
     my ($new_upstream, $upstream_version) = @_;
 
     if (!defined $new_upstream) {
        my @tried;
-       # todo: at some point maybe use git-deborig to do this
-       foreach my $tagpfx ('', 'v', 'upstream/') {
-           my $tag = $tagpfx.(dep14_version_mangle $upstream_version);
-           $new_upstream = git_get_ref "refs/tags/$tag";
-           last if length $new_upstream;
-           push @tried, $tag;
-       }
+       $new_upstream = upstream_commitish_search $upstream_version, \@tried;
        if (!length $new_upstream) {
            fail "Could not determine appropriate upstream commitish.\n".
                " (Tried these tags: @tried)\n".