{"thread":{"id":"34699","subject":"Bug: commit -p breaks with -m","startedAt":"2013-08-15T04:43:39Z","lastAt":"2013-08-15T17:31:58Z","messageCount":4,"participants":["Matan Nassau","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"225247","messageId":"6EC98F2F-98FC-439B-BD9C-B1D0DB1F5E10@gmail.com","threadId":"34699","inReplyTo":null,"subject":"Bug: commit -p breaks with -m","fromName":"Matan Nassau","fromEmail":"matan.nassau@gmail.com","sentAt":"2013-08-15T04:43:39Z","receivedAt":"2013-08-15T04:43:39Z","isPatch":false,"sender":{"key":"matan.nassau@gmail.com","avatar":null},"body":"With git 1.8.3.3,\n\n $ seq 5 >data\n $ git add data\n $ git commit -mdata\n $ sed -i '2 d' data\n $ git commit -pmchange\n\nAt the prompt, type e to edit the hunk. The editor doesn't start, but git records a commit.\n\nI found that builtin/commit.c sets the GIT_EDITOR env var to \":\" when the user specifies the -m option. This was done in 406400ce4f69. Removing these two lines,\n\n if (!use_editor)\n     setenv(\"GIT_EDITOR\", \":\", 1);\n\nseems to fix the issue, but I'm not sure this won't break the prepare-commit-msg hook. I'd like to submit a patch: can I get a hint if this change would break commit hooks or anything else I'm not seeing?"},{"id":"225260","messageId":"20130815121635.GB22102@sigill.intra.peff.net","threadId":"34699","inReplyTo":"6EC98F2F-98FC-439B-BD9C-B1D0DB1F5E10@gmail.com","subject":"Re: Bug: commit -p breaks with -m","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-15T12:16:35Z","receivedAt":"2013-08-15T12:16:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 15, 2013 at 12:43:39AM -0400, Matan Nassau wrote:\n\n> With git 1.8.3.3,\n> \n>  $ seq 5 >data\n>  $ git add data\n>  $ git commit -mdata\n>  $ sed -i '2 d' data\n>  $ git commit -pmchange\n> \n> At the prompt, type e to edit the hunk. The editor doesn't start, but\n> git records a commit.\n> \n> I found that builtin/commit.c sets the GIT_EDITOR env var to \":\" when\n> the user specifies the -m option. This was done in 406400ce4f69.\n> Removing these two lines,\n> \n>  if (!use_editor)\n>      setenv(\"GIT_EDITOR\", \":\", 1);\n> \n> seems to fix the issue, but I'm not sure this won't break the\n> prepare-commit-msg hook. I'd like to submit a patch: can I get a hint\n> if this change would break commit hooks or anything else I'm not\n> seeing?\n\nYeah, that is definitely a bug. Just removing those lines would not be the\nright fix, though, because the point of them is to let the\nprepare-commit-msg hook know whether or not an editor is in use.\n\nInstead, I think you would want to limit the scope of where we have set\nGIT_EDITOR. I.e., drop those lines, and then add GIT_EDITOR=: to the\nenvironment that we pass to the hook via the run_hook function.\nUnfortunately, I think that will require some refactoring of the\nrun_hook interface, which does not allow arbitrary environment\nparameters to be set.\n\n-Peff\n"},{"id":"225267","messageId":"7v1u5usw27.fsf@alter.siamese.dyndns.org","threadId":"34699","inReplyTo":"20130815121635.GB22102@sigill.intra.peff.net","subject":"Re: Bug: commit -p breaks with -m","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-15T17:28:16Z","receivedAt":"2013-08-15T17:28:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Unfortunately, I think that will require some refactoring of the\n> run_hook interface, which does not allow arbitrary environment\n> parameters to be set.\n\nHeh, I said that long time ago, e.g. $gmane/212284 ;-)\n\nThis might turn out to be a good starting point, even though I\ndidn't read it again before sending this message.\n\n    http://thread.gmane.org/gmane.comp.version-control.git/192669/focus=192806\n"},{"id":"225269","messageId":"20130815173158.GA27866@sigill.intra.peff.net","threadId":"34699","inReplyTo":"7v1u5usw27.fsf@alter.siamese.dyndns.org","subject":"Re: Bug: commit -p breaks with -m","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-15T17:31:58Z","receivedAt":"2013-08-15T17:31:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 15, 2013 at 10:28:16AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > Unfortunately, I think that will require some refactoring of the\n> > run_hook interface, which does not allow arbitrary environment\n> > parameters to be set.\n> \n> Heh, I said that long time ago, e.g. $gmane/212284 ;-)\n> \n> This might turn out to be a good starting point, even though I\n> didn't read it again before sending this message.\n> \n>     http://thread.gmane.org/gmane.comp.version-control.git/192669/focus=192806\n\nLooking at both of those messages, I agree completely. I even started\nto sketch out the refactoring when I sent the previous message, and it\nlooked a lot like the patch you sent.\n\n-Peff\n"}]}