chiark / gitweb /
Dgit.pm: read_tree_*: Treat '' as meaning 'delete this'
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 02cf97d846cd695f158245e6b3a4057dd4ab7958..437e18b17f979d5338cd4c783c92e7e21f067443 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -80,7 +80,10 @@ our $rmchanges;
 our $overwrite_version; # undef: not specified; '': check changelog
 our $quilt_mode;
 our $quilt_upstream_commitish;
-our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied|baredebian';
+our $quilt_upstream_commitish_used;
+our $quilt_upstream_commitish_message;
+our $quilt_options_re = 'gbp|dpm|baredebian';
+our $quilt_modes_re = "linear|smash|auto|nofix|nocheck|unapplied|$quilt_options_re";
 our $splitview_mode;
 our $splitview_modes_re = qr{auto|always|never};
 our $dodep14tag;
@@ -5409,13 +5412,14 @@ END
        # upstream and debian/ files from HEAD.
 
        read_tree_upstream $quilt_upstream_commitish, 1, $headref;
-       my $upsversion = upstreamversion getfield $clogp, 'Version';
+       my $version = getfield $clogp, 'Version';
+       my $upsversion = upstreamversion $version;
        my $merge = make_commit
            [ $headref, $quilt_upstream_commitish ],
          [ +(f_ <<ENDT, $upsversion), <<ENDU ];
[ +(f_ <<ENDT, $upsversion), $quilt_upstream_commitish_message, <<ENDU ];
 Combine debian/ with upstream source for %s
 ENDT
-[dgit ($our_version) baredebian-merge]
+[dgit ($our_version) baredebian-merge $version $quilt_upstream_commitish_used]
 ENDU
        runcmd @git, qw(reset -q --hard), $merge;
     }
@@ -6192,6 +6196,10 @@ END
 
     if ($quilt_mode =~ m/baredebian/) {
        $uheadref = $quilt_upstream_commitish;
+       # TRANSLATORS: this translation must fit in the ASCII art
+       # quilt differences display.  The untranslated display
+       # says %9.9s, so with that display it must be at most 9
+       # characters.
        $uhead_whatshort = __ 'upstream';
     }
 
@@ -6218,6 +6226,12 @@ END
     progress f_
 "%s: base trees orig=%.20s o+d/p=%.20s",
               $us, $unapplied, $oldtiptree;
+    # TRANSLATORS: Try to keep this ascii-art layout right.  The 0s in
+    # %9.00009s will be ignored and are there to make the format the
+    # same length (9 characters) as the output it generates.  If you
+    # change the value 9, your translation of "upstream" must fit into
+    # the new length, and you should change the number of 0s.  Do
+    # not reduce it below 4 as HEAD has to fit too.
     progress f_
 "%s: quilt differences: src:  %s orig %s     gitignores:  %s orig %s\n".
 "%s: quilt differences: %9.00009s %s o+d/p          %9.00009s %s o+d/p",
@@ -6376,6 +6390,18 @@ sub clean_tree_check () {
 sub clean_tree () {
     # We always clean the tree ourselves, rather than leave it to the
     # builder (dpkg-source, or soemthing which calls dpkg-source).
+    if ($quilt_mode =~ m/baredebian/ and $cleanmode =~ m/git/) {
+       fail f_ <<END, $quilt_mode, $cleanmode;
+quilt mode %s (generally needs untracked upstream files)
+contradicts clean mode %s (which would delete them)
+END
+       # This is not 100% true: dgit build-source and push-source
+       # (for example) could operate just fine with no upstream
+       # source in the working tree.  But it doesn't seem likely that
+       # the user wants dgit to proactively delete such things.
+       # -wn, for example, would produce identical output without
+       # deleting anything from the working tree.
+    }
     if ($cleanmode =~ m{^dpkg-source}) {
        my @cmd = @dpkgbuildpackage;
        push @cmd, qw(-d) if $cleanmode =~ m{^dpkg-source-d};
@@ -6427,11 +6453,12 @@ sub build_or_push_prep_modes () {
        if do_split_brain() && $includedirty;
 
     if (madformat_wantfixup $format and $quilt_mode =~ m/baredebian$/) {
-       my ($dummy, $umessage);
-       ($quilt_upstream_commitish, $dummy, $umessage) =
-       resolve_upstream_version
+       ($quilt_upstream_commitish, $quilt_upstream_commitish_used,
+        $quilt_upstream_commitish_message)
+           = resolve_upstream_version
            $quilt_upstream_commitish, upstreamversion $version;
-       progress f_ "dgit: --quilt=%s, %s", $quilt_mode, $umessage;
+       progress f_ "dgit: --quilt=%s, %s", $quilt_mode,
+           $quilt_upstream_commitish_message;
     } elsif (defined $quilt_upstream_commitish) {
        fail __
  "dgit: --upstream-commitish only makes sense with --quilt=baredebian"
@@ -7367,7 +7394,7 @@ sub parseopts () {
                push @ropts, $_;
                my $cmd = shift @$om;
                @$om = ($cmd, grep { $_ ne $2 } @$om);
-           } elsif (m/^--(gbp|dpm|baredebian)$/s) {
+           } elsif (m/^--($quilt_options_re)$/s) {
                push @ropts, "--quilt=$1";
                $quilt_mode = $1;
            } elsif (m/^--(?:ignore|include)-dirty$/s) {