From bc3be36a946aeb6485259be594645c3c3d69550f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 4 Aug 2018 14:28:16 +0100 Subject: git-debrebase: check for git-rebase in progress and abort most operations scrap should abort, but doesn't yet. status just prints a message. Signed-off-by: Ian Jackson --- debian/changelog | 1 + git-debrebase | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/debian/changelog b/debian/changelog index 787cd2c..fdd5509 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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: check for git-rebase in progress and abort most operations. -- diff --git a/git-debrebase b/git-debrebase index 4046425..f4831c3 100755 --- a/git-debrebase +++ b/git-debrebase @@ -975,6 +975,18 @@ sub update_head_postlaunder ($$$) { 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(); @@ -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 + bail_if_rebasing(); 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 () { + bail_if_rebasing(); # => ($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 "you are currently rebasing\n" if currently_rebasing(); } 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; + bail_if_rebasing(); my $old_head = get_head(); my $new = make_patches $old_head; my $d = get_differs $old_head, $new; -- cgit v1.2.3