Re: [RFC PATCH v2 2/2] rebase-interactive: warn if commit is dropped with --edit-todo

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

 



Hi Alban

Thanks for working on this. I've got a couple of specific comments below. On a more general level I'd be tempted to squash the two patches together rather than adding the tests as a separate commit. Also I think before we discussed having `rebase --continue` refuse to continue if `rebase --edit-todo` had dropped commits when rebase.missingCommitsCheck was set to error. I think that would be useful but could always come later. --edit-todo could write a file to .git/rebase-merge to prevent --continue from continuing in case of errors.

On 04/11/2019 09:54, Alban Gruin wrote:
This adds the ability for --edit-todo to check if commits were dropped
by the user.  As both edit_todo_list() and complete_action() parse the
todo list and check for dropped commits, the code doing so in the latter
is removed to reduce duplication.

Tests added previously should work now.

Signed-off-by: Alban Gruin <alban.gruin@xxxxxxxxx>
---
  rebase-interactive.c          | 7 +++----
  sequencer.c                   | 5 +----
  t/t3404-rebase-interactive.sh | 4 ++--
  3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/rebase-interactive.c b/rebase-interactive.c
index aa18ae82b7..1b8d7f25bf 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -115,10 +115,9 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list,
  	if (initial && new_todo->buf.len == 0)
  		return -3;
- /* For the initial edit, the todo list gets parsed in
-	 * complete_action(). */
-	if (!initial)
-		return todo_list_parse_insn_buffer(r, new_todo->buf.buf, new_todo);
+	if (todo_list_parse_insn_buffer(r, new_todo->buf.buf, new_todo) ||
+	    todo_list_check(todo_list, new_todo))
+		return -4;
return 0;
  }
diff --git a/sequencer.c b/sequencer.c
index 9d5964fd81..92f2e6f6a0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5062,10 +5062,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
  		todo_list_release(&new_todo);
return error(_("nothing to do"));
-	}
-
-	if (todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo) ||
-	    todo_list_check(todo_list, &new_todo)) {
+	} else if (res == -4) {
  		fprintf(stderr, _(edit_todo_list_advice));

Do we want to print this advice when `rebase --edit-todo` detects dropped commits as well? I'm not clear what error messages are printed it that case. If we always want this printed then it could be moved into edit_todo_list()

Thanks again for working on this, it's a really useful addition to rebase

Best Wishes

Phillip

  		checkout_onto(r, opts, onto_name, &onto->object.oid, orig_head);
  		todo_list_release(&new_todo);
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index be8badf7b3..040ec616f3 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1366,7 +1366,7 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ig
  		actual
  '
-test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
+test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
  	cat >expect <<-EOF &&
  	error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
  	Warning: some commits may have been dropped accidentally.
@@ -1395,7 +1395,7 @@ test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
  		actual
  '
-test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
+test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
  	cat >expect <<-EOF &&
  	error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
  	Warning: some commits may have been dropped accidentally.




[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