git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/7] sequencer: handle cherry-pick conflict in last commit

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Nov 13, 2011, 10:46 UTC
Message-ID
<1321181181-23923-5-git-send-email-artagnon@gmail.com>
In-Reply-To
<1321181181-23923-1-git-send-email-artagnon@gmail.com>

The previous two commits in the series implement special handling for the single-commit cherry-pick case. Although we can technically revert the changes made by d3f4628e (revert: Remove sequencer state when no commits are pending, 2011-06-06) without breaking any existing tests now, there is one pending corner case: when a cherry-pick is invoked on a commit range, and a conflict that occurs in the last commit is concluded with a 'git commit'. Without d3f4628e, we'd have the following unpleasant case:

  $ git cherry-pick foo..bar
  ... .git/sequencer is created ...
  ... .git/CHERRY_PICK_HEAD is created ...
  ... conflict in bar ...
  $ echo "resolved" >problematicfile
  $ git add problematicfile
  $ git commit
  ... .git/CHERRY_PICK_HEAD is removed ...
  $ git cherry-pick moo
  error: An existing cherry-pick or revert is in progress
  $ git cherry-pick --continue
  ... .git/sequencer is removed ...
  # We're in pristine shape now

While prematurely removing the entire sequencer state is an overkill, we can revise our plan: prematurely remove only '.git/sequencer/todo' in the 'REPLAY_PICK' case, because this is the exact case where the information in '.git/sequencer/todo' can be inferred from '.git/CHERRY_PICK_HEAD'. This will be compatible with our future plan to implement '--continue' and '--reset' consistently.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sequencer.c                     |    8 +++-----
 t/t3510-cherry-pick-sequence.sh |    4 ++--
 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index b35fcc7..23fd3fe 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -753,15 +753,13 @@ static int pick_commits(struct replay_insn_list *todo_list,
 		save_todo(cur);
 		res = do_pick_commit(cur->operand, cur->action, opts);
 		if (res) {
-			if (!cur->next)
+			if (!cur->next && opts->action == REPLAY_PICK)
 				/*
 				 * An error was encountered while
 				 * picking the last commit; the
-				 * sequencer state is useless now --
-				 * the user simply needs to resolve
-				 * the conflict and commit
+				 * sequencer todo is useless now.
 				 */
-				remove_sequencer_state(0);
+				unlink(git_path(SEQ_TODO_FILE));
 			return res;
 		}
 	}
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index 4b12244..09b9e65 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -85,10 +85,10 @@ test_expect_success '--reset cleans up sequencer state' '
 	test_path_is_missing .git/sequencer
 '
 
-test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' '
+test_expect_success 'cherry-pick cleans up sequencer todo when one commit is left' '
 	pristine_detach initial &&
 	test_must_fail git cherry-pick base..picked &&
-	test_path_is_missing .git/sequencer &&
+	test_path_is_missing .git/sequencer/todo &&
 	echo "resolved" >foo &&
 	git add foo &&
 	git commit &&
-- 
1.7.6.351.gb35ac.dirty
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 9 of 17 in “New sequencer workflow!”
  1. 0/7 New sequencer workflow!Ramkumar Ramachandra, Nov 13, 2011
  2. 1/7 sequencer: factor code out of revert builtinRamkumar Ramachandra, Nov 13, 2011
  3. 2/7 sequencer: invalidate sequencer state without todoRamkumar Ramachandra, Nov 13, 2011
  4. 3/7 sequencer: handle single-commit pick as special caseRamkumar Ramachandra, Nov 13, 2011
  5. Junio C HamanoNov 13, 2011
  6. Ramkumar RamachandraNov 15, 2011
  7. Junio C HamanoNov 15, 2011
  8. Ramkumar RamachandraNov 16, 2011
  9. 4/7 sequencer: handle cherry-pick conflict in last commitRamkumar Ramachandra, Nov 13, 2011
  10. 5/7 sequencer: introduce git-sequencer builtinRamkumar Ramachandra, Nov 13, 2011
  11. 6/7 sequencer: teach '--continue' how to commitRamkumar Ramachandra, Nov 13, 2011
  12. 7/7 sequencer: teach parser about CHERRY_PICK_HEADRamkumar Ramachandra, Nov 13, 2011
  13. Junio C HamanoNov 13, 2011
  14. Junio C HamanoNov 14, 2011
  15. Ramkumar RamachandraNov 15, 2011
  16. Phil HordNov 15, 2011
  17. Ramkumar RamachandraNov 15, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.