chiark / gitweb /
git-debrebase: Implement make-patches
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Apr 2018 23:32:43 +0000 (00:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 21:40:13 +0000 (22:40 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase
git-debrebase.1.pod
git-debrebase.5.pod
tests/tests/gdr-subcommands

index 7d5d5bdd72254bc0dcbac180037d0355095d58cb..7c8d54dbc558208a1aecb7bfa890275f8ca4d2ac 100755 (executable)
@@ -1362,6 +1362,44 @@ sub make_patches_staged ($) {
     };
 }
 
+sub make_patches ($) {
+    my ($head) = @_;
+    keycommits $head, 0, \&snag;
+    make_patches_staged $head;
+    my $out;
+    in_workarea sub {
+       my $ptree = cmdoutput @git, qw(write-tree --prefix=debian/patches/);
+       runcmd @git, qw(read-tree), $head;
+       read_tree_subdir 'debian/patches', $ptree;
+       $out = make_commit [$head], [
+            'Commit patch queue (exported by git-debrebase)',
+            '[git-debrebase: export and commit patches]',
+        ];
+    };
+    my $d = get_differs $head, $out;
+    if ($d == 0) {
+       return undef; # nothing to do
+    } elsif ($d == D_PAT_ADD) {
+       return $out; # OK
+    } else {
+       fail "Patch export produced patch amendments".
+           " (abandoned output commit $out).".
+           "  Try laundering first.";
+    }
+}
+
+sub cmd_make_patches () {
+    badusage "no arguments allowed" if @ARGV;
+    my $old_head = get_head();
+    my $new = make_patches $old_head;
+    snags_maybe_bail();
+    if (!$new) {
+       fail "No (more) patches to export." unless $opt_noop_ok;
+       return;
+    }
+    update_head_checkout $old_head, $new, 'make-patches';
+}
+
 sub cmd_convert_from_gbp () {
     badusage "needs 1 optional argument, the upstream git rev"
        unless @ARGV<=1;
index 9f82a7c311365bc43b171891d3294cc34be1dfb0..5da532029049951d43682eed5671df153e3e75e1 100644 (file)
@@ -188,6 +188,27 @@ that its command line syntax is optimal.
 We may want to introduce an incompatible replacement syntax
 under the name C<new-upstream>.
 
+=item git-debrebase make-patches
+
+Generate patches in debian/patches/
+representing the changes made to upstream files.
+
+It is not normally necessary to run this command explicitly.
+When uploading to Debian,
+dgit and git-debrebase
+will cooperate to regenerate patches as necessary.
+When working with pure git remotes,
+the patches are not needed.
+
+Normally git-debrebase make-patches will
+require a laundered branch.
+(A laundered branch does not contain any patches.)
+But if there are already some patches made by
+git-debrebase make-patches,
+and all that has happened is that more
+changes to upstream files have been committed,
+running it again can add the missing patches.
+
 =item git-debrebase convert-from-gbp [<upstream-commit-ish>]
 
 Cnnverts a gbp patches-unapplied branch
index 6ae094f00077ad4f84fc53f11da19f85067d1264..5cfa3761080eb5c6accffa98cfd6682b72cbffa0 100644 (file)
@@ -501,6 +501,7 @@ The full set of annotations is:
   [git-debrebase upstream-combine . PIECE[ PIECE...]: new upstream]
   [git-debrebase anchor: new upstream NEW-UPSTREAM-VERSION, merge]
   [git-debrebase: new upstream NEW-UPSTREAM-VERSION, changelog]
+  [git-debrebase: export and commit patches]
 
   [git-debrebase convert-from-gbp: drop patches]
   [git-debrebase anchor: declare upstream]
index 2a90cdc0680c404d60c1884936d0ef85064538dc..9d50b6c04f7db9134b4752ae1565854577be6bcc 100755 (executable)
@@ -138,7 +138,7 @@ make_check () {
                git reset --hard HEAD^1
                ;;
        P*)
-               t-dgit -wgf --quilt=check quilt-fixup
+               t-dgit -wgf --quilt=nofix quilt-fixup
                git diff HEAD~ debian/patches | egrep .
                git diff --quiet HEAD~ -- ':.' ':!debian/patches'
                git reset --hard HEAD~
@@ -160,6 +160,7 @@ make_check () {
 }
 
 Ec="F:No ongoing git-debrebase session"
+Ep="F:Patch export produced patch amendments"
 
 # input state:
 #  stitched?           st'd    st'd    unst'd  unst'd
@@ -174,8 +175,8 @@ subcmd      stitch          Ns      Nu      Sltf    Stf
 subcmd prepush         Ns      Nu      Sltf    Stf
 subcmd quick           ns      Sl      Sltf    Sl
 subcmd conclude        "$Ec"   "$Ec"   Sltf    Sl
-#subcmd        make-patches    sPft    sPft    uPft    uPft
-#subcmd        dgit-upload-hook Psft   Psft    SPft    SPft
+subcmd make-patches    sPft    "$Ep"   uPft    "$Ep"
+#subcmd        dgit-upload-hook Psft   "$Ep"   SPft    "$Ep"
 #
 # result codes, each one is a check:
 #   E:$pat     } this is an error (must come first)