{"thread":{"id":"35029","subject":"Problem switching branches in submodule","startedAt":"2013-09-26T17:20:50Z","lastAt":"2013-09-26T23:44:59Z","messageCount":6,"participants":["Manish Gill","Jonathan Nieder","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"228280","messageId":"BLU0-SMTP17403D5452DA1619FEFCCBAB8280@phx.gbl","threadId":"35029","inReplyTo":null,"subject":"Problem switching branches in submodule","fromName":"Manish Gill","fromEmail":"mgill25@outlook.com","sentAt":"2013-09-26T17:20:50Z","receivedAt":"2013-09-26T17:20:50Z","isPatch":false,"sender":{"key":"mgill25@outlook.com","avatar":null},"body":"Hello,\n\nI have a git repository with lots of submodules. In one particular\nsubmodule, I'm having the following problem:\n\nIf I try to switch branches at the top-level of that submodule, I succeed.\n\nBut, if I try to switch branches in any subsequen levels, I get the\nfollowing error:\n\n    fatal: internal error: work tree has already been set\n    Current worktree: ../path/Mailman3/rest_project\n    New worktree: ../path/Mailman3/rest_project/website/public_rest\n\nHere, Mailman3 is the primary repository and \"rest_project\" is a\nsubmodule. I can do \"git checkout\" just fine\ninside rest_project, but not after cd-ing into any other repos.\n\nMy git version is 1.8.4\n\nOther commands, like git status, push/pull are working fine.\n\nI'd appreciate any help. Thank you.\n\n"},{"id":"228281","messageId":"20130926180852.GF9464@google.com","threadId":"35029","inReplyTo":"BLU0-SMTP17403D5452DA1619FEFCCBAB8280@phx.gbl","subject":"Re: Problem switching branches in submodule","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-09-26T18:08:52Z","receivedAt":"2013-09-26T18:08:52Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(cc-ing Duy, who knows the setup code well)\nManish Gill wrote:\n\n> I have a git repository with lots of submodules. In one particular\n> submodule, I'm having the following problem:\n>\n> If I try to switch branches at the top-level of that submodule, I succeed.\n>\n> But, if I try to switch branches in any subsequen levels, I get the\n> following error:\n>\n>     fatal: internal error: work tree has already been set\n>     Current worktree: ../path/Mailman3/rest_project\n>     New worktree: ../path/Mailman3/rest_project/website/public_rest\n>\n> Here, Mailman3 is the primary repository and \"rest_project\" is a\n> submodule. I can do \"git checkout\" just fine\n> inside rest_project, but not after cd-ing into any other repos.\n>\n> My git version is 1.8.4\n>\n> Other commands, like git status, push/pull are working fine.\n\nInteresting.  Yeah, this shouldn't happen.\n\nWhat is the exact command you use to get the above output?  Is your\nrepository public (which would let us reproduce it) or can you\nreproduce it by creating a small artificial test repository?\n\nFor comparison, did some previous version of git work ok in the same\nscenario, or is this the first time you've tried it?\n\nThanks,\nJonathan\n"},{"id":"228283","messageId":"BLU0-SMTP36066CF18FF63C9BD84AC48B8280@phx.gbl","threadId":"35029","inReplyTo":"20130926180852.GF9464@google.com","subject":"Re: Problem switching branches in submodule","fromName":"Manish Gill","fromEmail":"mgill25@outlook.com","sentAt":"2013-09-26T18:33:23Z","receivedAt":"2013-09-26T18:33:23Z","isPatch":false,"sender":{"key":"mgill25@outlook.com","avatar":null},"body":"On 09/26/2013 11:38 PM, Jonathan Nieder wrote:\n> (cc-ing Duy, who knows the setup code well)\n> Manish Gill wrote:\n> \n>> I have a git repository with lots of submodules. In one particular\n>> submodule, I'm having the following problem:\n>>\n>> If I try to switch branches at the top-level of that submodule, I succeed.\n>>\n>> But, if I try to switch branches in any subsequen levels, I get the\n>> following error:\n>>\n>>     fatal: internal error: work tree has already been set\n>>     Current worktree: ../path/Mailman3/rest_project\n>>     New worktree: ../path/Mailman3/rest_project/website/public_rest\n>>\n>> Here, Mailman3 is the primary repository and \"rest_project\" is a\n>> submodule. I can do \"git checkout\" just fine\n>> inside rest_project, but not after cd-ing into any other repos.\n>>\n>> My git version is 1.8.4\n>>\n>> Other commands, like git status, push/pull are working fine.\n> \n> Interesting.  Yeah, this shouldn't happen.\n> \n> What is the exact command you use to get the above output?  \n\ngit checkout <branch_name>\n\nIs your\n> repository public (which would let us reproduce it) or can you\n> reproduce it by creating a small artificial test repository\n\nThe repo isn't public, I'm afraid.\n\nI should mention what *exactly* happened that led to this. I was trying\nto publish my branch on Launchpad (using git-remote-bzr). At some point,\nI had the genius idea to remote the extra stuff from the config file and\njust try with the bzr:: remote as origin, and instead of doing it via\nthe console, I just replaced the config file.\n\nAnnnnyway, I just restored my backed up config file for that submodule\nin the middle of writing this and seems like things seem to work now.\n\nI dunno, this was most likely because of some configuration derp on my\npart (the new config file didn't contain the branch information most\nlikely). So I guess problem solved!\n\nThanks for your help.\n\n\n"},{"id":"228284","messageId":"20130926184830.GG9464@google.com","threadId":"35029","inReplyTo":"BLU0-SMTP36066CF18FF63C9BD84AC48B8280@phx.gbl","subject":"Re: Problem switching branches in submodule","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-09-26T18:48:30Z","receivedAt":"2013-09-26T18:48:30Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Manish Gill wrote:\n> Jonathan Nieder wrote:\n\n>> What is the exact command you use to get the above output?\n>\n> git checkout <branch_name>\n\nIs <branch_name> a normal branch, a remote-tracking branch, or a\nbranch that doesn't exist yet?\n\n[...]\n> I should mention what *exactly* happened that led to this. I was trying\n> to publish my branch on Launchpad (using git-remote-bzr). At some point,\n> I had the genius idea to remote the extra stuff from the config file and\n> just try with the bzr:: remote as origin, and instead of doing it via\n> the console, I just replaced the config file.\n>\n> Annnnyway, I just restored my backed up config file for that submodule\n> in the middle of writing this and seems like things seem to work now.\n\nIf you happen to have a copy of the old config file or remember what it\nsaid, that could be helpful (especially if you can still reproduce the\nproblem in case we come up with a fix).\n\nDid the config file have a [core] worktree setting or something similar?\n\nHmm,\nJonathan\n"},{"id":"228285","messageId":"BLU0-SMTP2754312DA341C7F3254F325B8280@phx.gbl","threadId":"35029","inReplyTo":"20130926184830.GG9464@google.com","subject":"Re: Problem switching branches in submodule","fromName":"Manish Gill","fromEmail":"mgill25@outlook.com","sentAt":"2013-09-26T19:29:02Z","receivedAt":"2013-09-26T19:29:02Z","isPatch":false,"sender":{"key":"mgill25@outlook.com","avatar":null},"body":"On 09/27/2013 12:18 AM, Jonathan Nieder wrote:\n> Manish Gill wrote:\n>> Jonathan Nieder wrote:\n> \n>>> What is the exact command you use to get the above output?\n>>\n>> git checkout <branch_name>\n> \n> Is <branch_name> a normal branch, a remote-tracking branch, or a\n> branch that doesn't exist yet?\n\nLocal branch that was supposed to track a remote branch.\n\n> \n> [...]\n>> I should mention what *exactly* happened that led to this. I was trying\n>> to publish my branch on Launchpad (using git-remote-bzr). At some point,\n>> I had the genius idea to remote the extra stuff from the config file and\n>> just try with the bzr:: remote as origin, and instead of doing it via\n>> the console, I just replaced the config file.\n>>\n>> Annnnyway, I just restored my backed up config file for that submodule\n>> in the middle of writing this and seems like things seem to work now.\n> \n> If you happen to have a copy of the old config file or remember what it\n> said, that could be helpful (especially if you can still reproduce the\n> problem in case we come up with a fix).\n\nConfig file which was NOT working:\nhttp://bpaste.net/show/oaWG3TQarH3BrdjDj5be/\n\nWorking config restored from backup:\nhttp://bpaste.net/show/nF3ap5fDEAwL9NyqdCmD/\n> \n> Did the config file have a [core] worktree setting or something similar?\n\nLooks like the working one had it and the other didn't. Adding the\n\"worktree\" setting seems to fix the problem. But shouldn't this work\nuniformly in the repo? Removing the [core] worktree gives the same\nerror, but only in directories inside the repo. Checkout still works on\nthe top-level. Seems a bit strange I guess.\n> \n> Hmm,\n> Jonathan\n> \n\n\n"},{"id":"228297","messageId":"CACsJy8DifMCL4QZV_jxgHaL1MLDi6nrgBTSuBcB69btfOJOWvA@mail.gmail.com","threadId":"35029","inReplyTo":"BLU0-SMTP17403D5452DA1619FEFCCBAB8280@phx.gbl","subject":"Re: Problem switching branches in submodule","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-09-26T23:44:59Z","receivedAt":"2013-09-26T23:44:59Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Sep 27, 2013 at 12:20 AM, Manish Gill <mgill25@outlook.com> wrote:\n> Hello,\n>\n> I have a git repository with lots of submodules. In one particular\n> submodule, I'm having the following problem:\n>\n> If I try to switch branches at the top-level of that submodule, I succeed.\n>\n> But, if I try to switch branches in any subsequen levels, I get the\n> following error:\n>\n>     fatal: internal error: work tree has already been set\n>     Current worktree: ../path/Mailman3/rest_project\n>     New worktree: ../path/Mailman3/rest_project/website/public_rest\n>\n\nCan you apply this patch, rebuild git and retry again? It will create\na coredump at \"fatal:...\", which might give me a clue what's going\non.. Once you get the coredump, open it with gdb, execute \"bt full\"\nand paste the output here.\n\ndiff --git a/usage.c b/usage.c\nindex ed14645..0403091 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -34,6 +34,7 @@ static NORETURN void usage_builtin(const char *err,\nva_list params)\n static NORETURN void die_builtin(const char *err, va_list params)\n {\n        vreportf(\"fatal: \", err, params);\n+       *(char*)0 = 1;\n        exit(128);\n }\n\n-- \nDuy\n"}]}