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

[PATCH] cherry-pick: allow to pick to unborn branches

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 6, 2016, 13:23 UTC
Message-ID
<69f7973e353f52a62157ca59af5027c9617506a4.1465219182.git.git@drmicha.warpmail.net>
In-Reply-To
<afafa51c-f950-594e-7142-5b28b1182add@drmicha.warpmail.net>

Currently, cherry-pick allows tp pick single commits to an empty HEAD but not multiple commits.

Allow the multiple commit case, too.
Reported-by: Fabrizio Cucci <fabrizio.cucci@gmail.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 sequencer.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 4687ad4..c6362d6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -888,6 +888,10 @@ static int sequencer_rollback(struct replay_opts *opts)
 			git_path_head_file());
 		goto fail;
 	}
+	if (is_null_sha1(sha1)) {
+		error(_("cannot abort from a branch yet to be born"));
+		goto fail;
+	}
 	if (reset_for_rollback(sha1))
 		goto fail;
 	remove_sequencer_state();
@@ -1086,11 +1090,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 	walk_revs_populate_todo(&todo_list, opts);
 	if (create_seq_dir() < 0)
 		return -1;
-	if (get_sha1("HEAD", sha1)) {
-		if (opts->action == REPLAY_REVERT)
-			return error(_("Can't revert as initial commit"));
-		return error(_("Can't cherry-pick into empty head"));
-	}
+	if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
+		return error(_("Can't revert as initial commit"));
 	save_head(sha1_to_hex(sha1));
 	save_opts(opts);
 	return pick_commits(todo_list, opts);
-- 
2.9.0.rc1.371.ge0ee742
Previous: Michael J GruberNext: Torsten Bögershausen
Message 3 of 7 in “error: Can't cherry-pick into empty head”
  1. Fabrizio CucciMay 28, 2016
  2. Michael J GruberJun 6, 2016
  3. cherry-pick: allow to pick to unborn branchesMichael J Gruber, Jun 6, 2016
  4. Torsten BögershausenJun 6, 2016
  5. Junio C HamanoJun 6, 2016
  6. Michael J GruberJun 7, 2016
  7. Junio C HamanoJun 7, 2016

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.