Commit 7ef62c4e3e891c47d0449ca61fcb3fa35a98ec51

Stefan Sperling 2020-02-24T21:31:31

disallow 'got rebase' while a histedit operation is in progress

diff --git a/got/got.1 b/got/got.1
index f40d55e..97deeed 100644
--- a/got/got.1
+++ b/got/got.1
@@ -1119,7 +1119,8 @@ If the edited history contains changes to files outside of the work tree's
 path prefix, the work tree cannot be used to edit the history of this branch.
 .Pp
 The
-.Cm got update
+.Cm got update ,
+.Cm got rebase ,
 and
 .Cm got integrate
 commands will refuse to run while a histedit operation is in progress.
diff --git a/got/got.c b/got/got.c
index 29a1cd6..e00e812 100644
--- a/got/got.c
+++ b/got/got.c
@@ -5362,6 +5362,7 @@ cmd_rebase(int argc, char *argv[])
 	struct got_object_id *branch_head_commit_id = NULL, *yca_id = NULL;
 	struct got_commit_object *commit = NULL;
 	int ch, rebase_in_progress = 0, abort_rebase = 0, continue_rebase = 0;
+	int histedit_in_progress = 0;
 	unsigned char rebase_status = GOT_STATUS_NO_CHANGE;
 	struct got_object_id_queue commits;
 	struct got_pathlist_head merged_paths;
@@ -5420,6 +5421,15 @@ cmd_rebase(int argc, char *argv[])
 	if (error)
 		goto done;
 
+	error = got_worktree_histedit_in_progress(&histedit_in_progress,
+	    worktree);
+	if (error)
+		goto done;
+	if (histedit_in_progress) {
+		error = got_error(GOT_ERR_HISTEDIT_BUSY);
+		goto done;
+	}
+
 	error = got_worktree_rebase_in_progress(&rebase_in_progress, worktree);
 	if (error)
 		goto done;