chiark / gitweb /
git-debrebase: check for git-rebase in progress and abort most operations
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Aug 2018 13:28:16 +0000 (14:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Aug 2018 13:29:32 +0000 (14:29 +0100)
scrap should abort, but doesn't yet.  status just prints a message.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
git-debrebase

index 787cd2caef26a681ee3840785c7cdd96a791a361..fdd5509636c7ba1b476d020d36d12e454e7a220b 100644 (file)
@@ -11,6 +11,7 @@ dgit (6.5~) unstable; urgency=medium
   * git-debrebase: Provide new convert-from-dgit-view operation.
     The output is, unavoidably, not very pretty.  Closes:#905322.
   * git-debrebase: New feature `scrap'.  Closes:#905063.
   * git-debrebase: Provide new convert-from-dgit-view operation.
     The output is, unavoidably, not very pretty.  Closes:#905322.
   * git-debrebase: New feature `scrap'.  Closes:#905063.
+  * git-debrebase: check for git-rebase in progress and abort most operations.
 
  --
 
 
  --
 
index 4046425e5fa92ffd66235a68e7833279af97370f..f4831c3c5b6c4f1a8a23cf58a1ebfeb0c074a7ce 100755 (executable)
@@ -975,6 +975,18 @@ sub update_head_postlaunder ($$$) {
     runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
 }
 
     runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
 }
 
+sub currently_rebasing() {
+    foreach (qw(rebase-merge rebase-apply)) {
+       return 1 if stat_exists "$maindir_gitdir/$_";
+    }
+    return 0;
+}
+
+sub bail_if_rebasing() {
+    fail "you are in the middle of a git-rebase already"
+       if currently_rebasing();
+}
+
 sub do_launder_head ($) {
     my ($reflogmsg) = @_;
     my $old = get_head();
 sub do_launder_head ($) {
     my ($reflogmsg) = @_;
     my $old = get_head();
@@ -1114,6 +1126,7 @@ sub record_ffq_prev_deferred () {
     # if "deferred", will have added something about that to
     #   @deferred_update_messages, and also maybe printed (already)
     #   some messages about ff checks
     # if "deferred", will have added something about that to
     #   @deferred_update_messages, and also maybe printed (already)
     #   some messages about ff checks
+    bail_if_rebasing();
     my $currentval = get_head();
 
     my ($status,$message, $ffq_prev,$gdrlast) = ffq_check $currentval;
     my $currentval = get_head();
 
     my ($status,$message, $ffq_prev,$gdrlast) = ffq_check $currentval;
@@ -1137,6 +1150,7 @@ sub record_ffq_auto () {
 }
 
 sub ffq_prev_info () {
 }
 
 sub ffq_prev_info () {
+    bail_if_rebasing();
     # => ($ffq_prev, $gdrlast, $ffq_prev_commitish)
     my ($status, $message, $current, $ffq_prev, $gdrlast)
        = ffq_prev_branchinfo();
     # => ($ffq_prev, $gdrlast, $ffq_prev_commitish)
     my ($status, $message, $current, $ffq_prev, $gdrlast)
        = ffq_prev_branchinfo();
@@ -1547,6 +1561,7 @@ sub cmd_status () {
            print "  not git-debrebase (diverged since last stitch)\n"
        }
     }
            print "  not git-debrebase (diverged since last stitch)\n"
        }
     }
+    print "you are currently rebasing\n" if currently_rebasing();
 }
 
 sub cmd_stitch () {
 }
 
 sub cmd_stitch () {
@@ -1633,6 +1648,7 @@ sub cmd_make_patches () {
     getoptions("make-patches",
               'quiet-would-amend!', \$opt_quiet_would_amend);
     badusage "no arguments allowed" if @ARGV;
     getoptions("make-patches",
               'quiet-would-amend!', \$opt_quiet_would_amend);
     badusage "no arguments allowed" if @ARGV;
+    bail_if_rebasing();
     my $old_head = get_head();
     my $new = make_patches $old_head;
     my $d = get_differs $old_head, $new;
     my $old_head = get_head();
     my $new = make_patches $old_head;
     my $d = get_differs $old_head, $new;