Package: dgit
Version: 9.10
Severity: important
X-debbugs-cc: brem...@debian.org

Hello,

Dgit::upstream_commitish_search() should fail, as git-deborig does, if
there is more than one of the three kinds of tags is looks for with the
same upstream version number.

How this can cause trouble:

    % git clone https://salsa.debian.org/debian/ledger.git
    % cd ledger
    % git remote add github https://github.com/ledger/ledger
    % git fetch --tags github
    % git checkout 722a502e82b95cc928468142895101af91e45e0b
    % git debrebase new-upstream 3.2.1

    Actual result: debrebase merges the v3.2.1 tag.

    Expected result: complain that both v3.2.1 and upstream/3.2.1 tags
    exist, and ask user to supply more arguments to new-upstream
    subcommand to indicate which they want to use.

Attached is a minimal fix.

-- 
Sean Whitton
From 0b881dddb050a7f0833bc37842082934492d23c6 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhit...@spwhitton.name>
Date: Wed, 27 May 2020 13:49:07 -0700
Subject: [PATCH] Dgit::upstream_commitish_search: fail if more than one tag
 exists

We should not assume we know which the user wants to merge, as
git-deborig does not.

Signed-off-by: Sean Whitton <spwhit...@spwhitton.name>
---
 Debian/Dgit.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm
index 5d898ae5..4e196570 100644
--- a/Debian/Dgit.pm
+++ b/Debian/Dgit.pm
@@ -634,12 +634,14 @@ sub git_check_unmodified () {
 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 if $new_upstream;
     }
+    return $found[0] if @found == 1;
 }
 
 sub resolve_upstream_version ($$) {
-- 
2.26.2

Attachment: signature.asc
Description: PGP signature

Reply via email to