chiark / gitweb /
dgit: Option parsing: quilt-fixup: Use build_prep_early
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 1e7c923eea6e8070b3f2254af6f8a85570d05aa4..0cac521012390f042ff7ccc8a392d224b17c7c82 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -96,6 +96,7 @@ our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
 
 our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$';
 our $splitbraincache = 'dgit-intern/quilt-cache';
+our $rewritemap = 'dgit-rewrite/map';
 
 our (@git) = qw(git);
 our (@dget) = qw(dget);
@@ -2513,6 +2514,7 @@ sub git_fetch_us () {
            \&debiantag_new, \&debiantag_maintview)
         : debiantags('*',access_nomdistro));
     push @specs, server_branch($csuite);
+    push @specs, $rewritemap;
     push @specs, qw(heads/*) if deliberately_not_fast_forward;
 
     # This is rather miserable:
@@ -2724,6 +2726,18 @@ sub fetch_from_archive () {
        progress "no version available from the archive";
     }
 
+    my $rewritemapdata = git_cat_file lrfetchrefs."/".$rewritemap.':map';
+    if (defined $rewritemapdata
+       && $rewritemapdata =~ m/^$dsc_hash(?:[ \t](\w+))/m) {
+       progress "server's git history rewrite map contains a relevant entry!";
+       $dsc_hash = $1;
+       if (defined $dsc_hash) {
+           progress "using rewritten git hash in place of .dsc value";
+       } else {
+           progress "server data says .dsc hash is to be disregarded";
+       }
+    }
+
     # If the archive's .dsc has a Dgit field, there are three
     # relevant git commitids we need to choose between and/or merge
     # together:
@@ -3538,7 +3552,7 @@ tree $tree
 parent $dgitview
 parent $archive_hash
 author $authline
-commiter $authline
+committer $authline
 
 $msg_msg
 
@@ -5803,10 +5817,7 @@ END
 
 sub cmd_quilt_fixup {
     badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;
-    my $clogp = parsechangelog();
-    $version = getfield $clogp, 'Version';
-    $package = getfield $clogp, 'Source';
-    check_not_dirty();
+    build_prep_early();
     clean_tree();
     build_maybe_quilt_fixup();
 }
@@ -5875,9 +5886,10 @@ sub cmd_import_dsc {
     parse_dscdata();
 
     my $dgit_commit = $dsc->{$ourdscfield[0]};
-    if (defined $dgit_commit && 
-       !forceing [qw(import-dsc-with-dgit-field)]) {
+    if (defined $dgit_commit
+       && !forceing [qw(import-dsc-with-dgit-field)]) {
        $dgit_commit =~ m/\w+/ or fail "invalid hash in .dsc";
+       $dgit_commit = $&;
        progress "dgit: import-dsc of .dsc with Dgit field, using git hash";
        my @cmd = (qw(sh -ec),
                   "echo $dgit_commit | git cat-file --batch-check");
@@ -5944,10 +5956,14 @@ END
            progress "Import, merging.";
            my $tree = cmdoutput @git, qw(rev-parse), "$newhash:";
            my $version = getfield $dsc, 'Version';
+           my $clogp = commit_getclogp $newhash;
+           my $authline = clogp_authline $clogp;
            $newhash = make_commit_text <<END;
 tree $tree
 parent $newhash
 parent $oldhash
+author $authline
+committer $authline
 
 Merge $package ($version) import into $dstbranch
 END