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

Re: checkout -m dumping core

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2010, 05:07 UTC
Message-ID
<7vaawq8pvf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<2b9e2ea1.461a9565.4b4445be.38bda@o2.pl>
Daniel <mjucde@o2.pl> writes:
> Does this patch help?

There actually is no point running parse_commit() at that point, as the code obtained old->commit from lookup_commit_reference_gently() in switch_branches() which must have already parsed it. We do use it to try switching the branches before falling back to the --merge mode (or we notice old->commit does not exist and switch from an empty tree).

Instead of silently dying without diagnosing what paths are problematic like your patch does, we can unsquelch the error from the unpack_tree() we run before falling back to the --merge mode, and allow it to notice and report the paths that will be overwritten (since you do not have HEAD, everything in the work tree will be overwritten). Perhaps like this.

 builtin-checkout.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 64f3a11..2708669 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -397,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 		topts.initial_checkout = is_cache_unborn();
 		topts.update = 1;
 		topts.merge = 1;
-		topts.gently = opts->merge;
+		topts.gently = opts->merge && old->commit;
 		topts.verbose_update = !opts->quiet;
 		topts.fn = twoway_merge;
 		topts.dir = xcalloc(1, sizeof(*topts.dir));
@@ -422,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts,
 			struct merge_options o;
 			if (!opts->merge)
 				return 1;
-			parse_commit(old->commit);
+
+			/*
+			 * Without old->commit, the below is the same as
+			 * the two-tree unpack we already tried and failed.
+			 */
+			if (!old->commit)
+				return 1;
 
 			/* Do more real merge */
 
Previous: Daniel
Message 3 of 3 in “checkout -m dumping core”
  1. Tomas CarneckyJan 5, 2010
  2. DanielJan 6, 2010
  3. Junio C HamanoJan 7, 2010

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.