{"thread":{"id":"34992","subject":"Using alternate working directory","startedAt":"2013-09-21T21:04:24Z","lastAt":"2013-09-24T05:00:11Z","messageCount":3,"participants":["Ram Rachum","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"228013","messageId":"523E09D8.8090808@rachum.com","threadId":"34992","inReplyTo":null,"subject":"Using alternate working directory","fromName":"Ram Rachum","fromEmail":"ram@rachum.com","sentAt":"2013-09-21T21:04:24Z","receivedAt":"2013-09-21T21:04:24Z","isPatch":false,"sender":{"key":"ram@rachum.com","avatar":"https://gravatar.com/avatar/e8ab34af7f6351b96e027ece1b3f9b3bd5d6362b38372071db2e6e4e6de5cce4?d=mp&s=160"},"body":"Hi everybody!\n\nI need some help with Git.\n\nI'm making a script `gm` which lets me merge one branch into another \nwithout having either checked out. It works for some cases but not all. \nI'm trying to make it work for more cases.\n\nI concluded that the best way to do it would be by using an alternate, \ntemporary working directory instead of the repo itself.\n\nThis is my script:\n\n     https://gist.github.com/cool-RR/6575042\n\nNow, the problem is that when I try it, it gives these errors:\n\n     git checkout-index: my_file is not in the cache and then error:\n     my_file: cannot add to the index - missing --add option?\n\nAnyone has any idea what to do?\n\nP.S. I've also asked this on Stack Overflow, so whoever comes up with an \nanswer can claim his 150 imaginary internet points on that question.\n\n\nThanks,\nRam.\n"},{"id":"228117","messageId":"524114B9.40001@rachum.com","threadId":"34992","inReplyTo":"523E09D8.8090808@rachum.com","subject":"Re: Using alternate working directory","fromName":"Ram Rachum","fromEmail":"ram@rachum.com","sentAt":"2013-09-24T04:27:37Z","receivedAt":"2013-09-24T04:27:37Z","isPatch":false,"sender":{"key":"ram@rachum.com","avatar":"https://gravatar.com/avatar/e8ab34af7f6351b96e027ece1b3f9b3bd5d6362b38372071db2e6e4e6de5cce4?d=mp&s=160"},"body":"Does anyone care to help? I'd really like to solve this  :(\n\nOn 22/9/2013 00:04, Ram Rachum wrote:\n> Hi everybody!\n>\n> I need some help with Git.\n>\n> I'm making a script `gm` which lets me merge one branch into another \n> without having either checked out. It works for some cases but not \n> all. I'm trying to make it work for more cases.\n>\n> I concluded that the best way to do it would be by using an alternate, \n> temporary working directory instead of the repo itself.\n>\n> This is my script:\n>\n>     https://gist.github.com/cool-RR/6575042\n>\n> Now, the problem is that when I try it, it gives these errors:\n>\n>     git checkout-index: my_file is not in the cache and then error:\n>     my_file: cannot add to the index - missing --add option?\n>\n> Anyone has any idea what to do?\n>\n> P.S. I've also asked this on Stack Overflow, so whoever comes up with \n> an answer can claim his 150 imaginary internet points on that question.\n>\n>\n> Thanks,\n> Ram.\n"},{"id":"228119","messageId":"20130924050011.GE2766@sigill.intra.peff.net","threadId":"34992","inReplyTo":"523E09D8.8090808@rachum.com","subject":"Re: Using alternate working directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-24T05:00:11Z","receivedAt":"2013-09-24T05:00:11Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 22, 2013 at 12:04:24AM +0300, Ram Rachum wrote:\n\n> I'm making a script `gm` which lets me merge one branch into another\n> without having either checked out. It works for some cases but not\n> all. I'm trying to make it work for more cases.\n> \n> I concluded that the best way to do it would be by using an\n> alternate, temporary working directory instead of the repo itself.\n\nYes, otherwise you will be stomping all over the working tree of\nwhatever branch _is_ checked out.\n\n> This is my script:\n> \n>     https://gist.github.com/cool-RR/6575042\n> \n> Now, the problem is that when I try it, it gives these errors:\n> \n>     git checkout-index: my_file is not in the cache and then error:\n>     my_file: cannot add to the index - missing --add option?\n> \n> Anyone has any idea what to do?\n\nYour script is quite similar to the one that is used server-side at\nGitHub to generate the \"this can be merged\" button for each pull\nrequest. So it should work in principle.\n\nJust a guess, but using a relative path for the temporary index file\nmight be a problem. read-tree will operate from $GIT_DIR as its working\ndirectory, for example, but I think the git-merge-one-file script will\nbe at the top-level of $GIT_WORK_TREE. Meaning that all of the\nsub-commands it runs will see an empty index.\n\n-Peff\n"}]}