chiark / gitweb /
quilt patchification: Break out quiltify() (nfc)
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 6d346207444184adb992f57b10445a986449fddb..87a038009a006ad1feaa5d28b7721caa122f7959 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2031,6 +2031,38 @@ our $dscfn;
 
 our $fakeeditorenv = 'DGIT_FAKE_EDITOR_QUILT';
 
+sub quiltify ($$) {
+    my ($clogp,$headref) = @_;
+
+    my $author = getfield $clogp, 'Maintainer';
+    my $time = time;
+    my $ncommits = 3;
+    my $patchname = "auto-$version-$headref-$time";
+    my $msg = cmdoutput @git, qw(log), "-n$ncommits";
+    mkpath '.git/dgit';
+    my $descfn = ".git/dgit/quilt-description.tmp";
+    open O, '>', $descfn or die "$descfn: $!";
+    $msg =~ s/\n/\n /g;
+    $msg =~ s/^\s+$/ ./mg;
+    print O <<END or die $!;
+Description: Automatically generated patch ($clogp->{Version})
+ Last (up to) $ncommits git changes, FYI:
+ .
+ $msg
+Author: $author
+
+---
+
+END
+    close O or die $!;
+    {
+       local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
+       local $ENV{'VISUAL'} = $ENV{'EDITOR'};
+       local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
+       runcmd_ordryrun_local @dpkgsource, qw(--commit .), $patchname;
+    }
+}
+
 sub build_maybe_quilt_fixup () {
     my $format=get_source_format;
     return unless madformat $format;
@@ -2149,33 +2181,7 @@ END
         rename '../fake/.pc','.pc' or die $!;
     }
 
-    my $author = getfield $clogp, 'Maintainer';
-    my $time = time;
-    my $ncommits = 3;
-    my $patchname = "auto-$version-$headref-$time";
-    my $msg = cmdoutput @git, qw(log), "-n$ncommits";
-    mkpath '.git/dgit';
-    my $descfn = ".git/dgit/quilt-description.tmp";
-    open O, '>', $descfn or die "$descfn: $!";
-    $msg =~ s/\n/\n /g;
-    $msg =~ s/^\s+$/ ./mg;
-    print O <<END or die $!;
-Description: Automatically generated patch ($clogp->{Version})
- Last (up to) $ncommits git changes, FYI:
- .
- $msg
-Author: $author
-
----
-
-END
-    close O or die $!;
-    {
-       local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
-       local $ENV{'VISUAL'} = $ENV{'EDITOR'};
-       local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
-       runcmd_ordryrun_local @dpkgsource, qw(--commit .), $patchname;
-    }
+    quiltify($clogp,$headref);
 
     if (!open P, '>>', ".pc/applied-patches") {
        $!==&ENOENT or die $!;