[GSoC][PATCH v2 1/3] sequencer: add advice for revert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the case of merge conflicts, while performing a revert, we are
currently advised to use `git cherry-pick --<sequencer-options>`
of which --continue is incompatible for continuing the revert.
Introduce a separate advice message for `git revert`. Also change
the signature of `create_seq_dir` to handle which advice to display
selectively.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@xxxxxxxxx>
---
what has changed:
    Following Phillip's advice, I've changed the signature of `create_seq_dir`
    to selectively handle which advice to display.

 sequencer.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index f88a97fb10..ffb0257f0f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2650,15 +2650,30 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
 	return 0;
 }
 
-static int create_seq_dir(void)
+static int create_seq_dir(struct repository *r)
 {
-	if (file_exists(git_path_seq_dir())) {
-		error(_("a cherry-pick or revert is already in progress"));
-		advise(_("try \"git cherry-pick (--continue | --quit | --abort)\""));
-		return -1;
-	} else if (mkdir(git_path_seq_dir(), 0777) < 0)
+	enum replay_action action;
+
+	if (!sequencer_get_last_command(r, &action)) {
+		switch (action) {
+		case REPLAY_REVERT:
+		case REPLAY_PICK:
+			error(_("a %s is already in progress"),
+				 action == REPLAY_REVERT ?
+				 "revert" : "cherry-pick");
+			advise(_("try \"git %s (--continue | "
+				 "--quit | --abort)\""),
+				 action == REPLAY_REVERT ?
+				 "revert" : "cherry-pick");
+			return -1;
+		default:
+			BUG(_("the control must not reach here"));
+		}
+	}
+	if (mkdir(git_path_seq_dir(), 0777) < 0)
 		return error_errno(_("could not create sequencer directory '%s'"),
 				   git_path_seq_dir());
+
 	return 0;
 }
 
@@ -4237,7 +4252,7 @@ int sequencer_pick_revisions(struct repository *r,
 	 */
 
 	if (walk_revs_populate_todo(&todo_list, opts) ||
-			create_seq_dir() < 0)
+			create_seq_dir(r) < 0)
 		return -1;
 	if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT))
 		return error(_("can't revert as initial commit"));
-- 
2.21.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux