{"thread":{"id":"22101","subject":"checkout -m dumping core","startedAt":"2010-01-05T18:15:38Z","lastAt":"2010-01-07T05:07:16Z","messageCount":3,"participants":["Tomas Carnecky","Daniel","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130851","messageId":"4B4381CA.1080504@dbservice.com","threadId":"22101","inReplyTo":null,"subject":"checkout -m dumping core","fromName":"Tomas Carnecky","fromEmail":"tom@dbservice.com","sentAt":"2010-01-05T18:15:38Z","receivedAt":"2010-01-05T18:15:38Z","isPatch":false,"sender":{"key":"tom@dbservice.com","avatar":"https://gravatar.com/avatar/900a300bdd1a8bbe086008ad78210bbee2ad2803b7d50a5cba04c1e9404bd6d2?d=mp&s=160"},"body":"git version 1.6.6.78.gbd757c\n\nHEAD points to a non-existent branch refs/heads/master. Normal checkout \norigin fails with:\nerror: Entry '.cvsignore' would be overwritten by merge. Cannot merge.\n(the working tree does indeed contain this file). So I tried checkout -m \nand git crashed. Workaround for me was reset --hard origin; checkout \norigin. I have the repository backed up in case someone wants to try \nthemselves.\n\n$ gdb `which git`\nGNU gdb 6.8\nCopyright (C) 2008 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later \n<http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"i386-pc-solaris2.11\"...\n(gdb) run checkout -m origin\nStarting program: /export/home/tomc/local/git/bin/git checkout -m origin\nwarning: Lowest section in /lib/libpthread.so.1 is .dynamic at 00000074\n\nProgram received signal SIGSEGV, Segmentation fault.\n0x080788fa in cmd_checkout (argc=0, argv=0x8047538, prefix=0x0) at \nbuiltin-checkout.c:450\n450                             merge_trees(&o, new->commit->tree, work,\n(gdb) list\n445                             ret = reset_tree(new->commit->tree, \nopts, 1);\n446                             if (ret)\n447                                     return ret;\n448                             o.branch1 = new->name;\n449                             o.branch2 = \"local\";\n450                             merge_trees(&o, new->commit->tree, work,\n451                                     old->commit->tree, &result);\n452                             ret = reset_tree(new->commit->tree, \nopts, 0);\n453                             if (ret)\n454                                     return ret;\n(gdb) p o\n$1 = {branch1 = 0x8047650 \"origin\", branch2 = 0x0, subtree_merge = 0, \nbuffer_output = 1, verbosity = 0, diff_rename_limit = -1, \nmerge_rename_limit = -1, call_depth = 0, obuf = {alloc = 0, len = 0, buf \n= 0x81643ac \"\"}, current_file_set = {\n     items = 0x0, nr = 0, alloc = 0, strdup_strings = 1}, \ncurrent_directory_set = {items = 0x0, nr = 0, alloc = 0, strdup_strings \n= 1}}\n(gdb) p new\n$2 = {name = 0x8047650 \"origin\", path = 0x8166438 \"refs/heads/origin\", \ncommit = 0x8168f48}\n(gdb) p work\n$3 = (struct tree *) 0x8174f90\n(gdb) p old\nNo symbol \"old\" in current context.\n(gdb) p result\n$4 = (struct tree *) 0xfefc81be\n(gdb)\n"},{"id":"130904","messageId":"2b9e2ea1.461a9565.4b4445be.38bda@o2.pl","threadId":"22101","inReplyTo":"4B4381CA.1080504@dbservice.com","subject":"Re: checkout -m dumping core","fromName":"Daniel","fromEmail":"mjucde@o2.pl","sentAt":"2010-01-06T08:11:42Z","receivedAt":"2010-01-06T08:11:42Z","isPatch":false,"sender":{"key":"mjucde@o2.pl","avatar":null},"body":"Tomas Carnecky <tom@dbservice.com> wrote:\n\n> git version 1.6.6.78.gbd757c\n> \n> HEAD points to a non-existent branch refs/heads/master. Normal checkout \n> origin fails with:\n> error: Entry '.cvsignore' would be overwritten by merge. Cannot merge.\n> (the working tree does indeed contain this file). So I tried checkout -m \n> and git crashed. Workaround for me was reset --hard origin; checkout \n> origin. I have the repository backed up in case someone wants to try \n> themselves.\n> \n> $ gdb `which git`\n> GNU gdb 6.8\n> Copyright (C) 2008 Free Software Foundation, Inc.\n> License GPLv3+: GNU GPL version 3 or later \n> <http://gnu.org/licenses/gpl.html>\n> This is free software: you are free to change and redistribute it.\n> There is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\n> and \"show warranty\" for details.\n> This GDB was configured as \"i386-pc-solaris2.11\"...\n> (gdb) run checkout -m origin\n> Starting program: /export/home/tomc/local/git/bin/git checkout -m origin\n> warning: Lowest section in /lib/libpthread.so.1 is .dynamic at 00000074\n> \n> Program received signal SIGSEGV, Segmentation fault.\n> 0x080788fa in cmd_checkout (argc=0, argv=0x8047538, prefix=0x0) at \n> builtin-checkout.c:450\n> 450                             merge_trees(&o, new->commit->tree, work,\n> (gdb) list\n> 445                             ret = reset_tree(new->commit->tree, \n> opts, 1);\n> 446                             if (ret)\n> 447                                     return ret;\n> 448                             o.branch1 = new->name;\n> 449                             o.branch2 = \"local\";\n> 450                             merge_trees(&o, new->commit->tree, work,\n> 451                                     old->commit->tree, &result);\n> 452                             ret = reset_tree(new->commit->tree, \n> opts, 0);\n> 453                             if (ret)\n> 454                                     return ret;\n> (gdb) p o\n> $1 = {branch1 = 0x8047650 \"origin\", branch2 = 0x0, subtree_merge = 0, \n> buffer_output = 1, verbosity = 0, diff_rename_limit = -1, \n> merge_rename_limit = -1, call_depth = 0, obuf = {alloc = 0, len = 0, buf \n> = 0x81643ac \"\"}, current_file_set = {\n>      items = 0x0, nr = 0, alloc = 0, strdup_strings = 1}, \n> current_directory_set = {items = 0x0, nr = 0, alloc = 0, strdup_strings \n> = 1}}\n> (gdb) p new\n> $2 = {name = 0x8047650 \"origin\", path = 0x8166438 \"refs/heads/origin\", \n> commit = 0x8168f48}\n> (gdb) p work\n> $3 = (struct tree *) 0x8174f90\n> (gdb) p old\n> No symbol \"old\" in current context.\n> (gdb) p result\n> $4 = (struct tree *) 0xfefc81be\n> (gdb)\n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n\nDoes this patch help?\n\n---\nFrom b2203bded22db1a496ee3c9f6f5f4a384a8ccefa Mon Sep 17 00:00:00 2001\nFrom: Daniel Baranski <mjucde@o2.pl>\nDate: Wed, 6 Jan 2010 08:58:21 +0100\nSubject: [PATCH] checkout -m: Fix SEGFAULT if HEAD is not valid.\n\nSigned-off-by: Daniel Barański <mjucde@o2.pl>\n---\n builtin-checkout.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 64f3a11..0ab59b2 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -422,7 +422,8 @@ static int merge_working_tree(struct checkout_opts *opts,\n                        struct merge_options o;\n                        if (!opts->merge)\n                                return 1;\n-                       parse_commit(old->commit);\n+                       if (!parse_commit(old->commit))\n+                               die(\"Couldn't parse commit '%s'\", old->path);\n\n                        /* Do more real merge */\n\n-- \n1.6.5.6\n"},{"id":"130978","messageId":"7vaawq8pvf.fsf@alter.siamese.dyndns.org","threadId":"22101","inReplyTo":"2b9e2ea1.461a9565.4b4445be.38bda@o2.pl","subject":"Re: checkout -m dumping core","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-07T05:07:16Z","receivedAt":"2010-01-07T05:07:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel <mjucde@o2.pl> writes:\n\n> Does this patch help?\n\nThere actually is no point running parse_commit() at that point, as the\ncode obtained old->commit from lookup_commit_reference_gently() in\nswitch_branches() which must have already parsed it.  We do use it to try\nswitching the branches before falling back to the --merge mode (or we\nnotice old->commit does not exist and switch from an empty tree).\n\nInstead of silently dying without diagnosing what paths are problematic\nlike your patch does, we can unsquelch the error from the unpack_tree() we\nrun before falling back to the --merge mode, and allow it to notice and\nreport the paths that will be overwritten (since you do not have HEAD,\neverything in the work tree will be overwritten).  Perhaps like this.\n\n builtin-checkout.c |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 64f3a11..2708669 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -397,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts,\n \t\ttopts.initial_checkout = is_cache_unborn();\n \t\ttopts.update = 1;\n \t\ttopts.merge = 1;\n-\t\ttopts.gently = opts->merge;\n+\t\ttopts.gently = opts->merge && old->commit;\n \t\ttopts.verbose_update = !opts->quiet;\n \t\ttopts.fn = twoway_merge;\n \t\ttopts.dir = xcalloc(1, sizeof(*topts.dir));\n@@ -422,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts,\n \t\t\tstruct merge_options o;\n \t\t\tif (!opts->merge)\n \t\t\t\treturn 1;\n-\t\t\tparse_commit(old->commit);\n+\n+\t\t\t/*\n+\t\t\t * Without old->commit, the below is the same as\n+\t\t\t * the two-tree unpack we already tried and failed.\n+\t\t\t */\n+\t\t\tif (!old->commit)\n+\t\t\t\treturn 1;\n \n \t\t\t/* Do more real merge */\n \n"}]}