{"thread":{"id":"45132","subject":"new git-diff switch to eliminate leading \"+\" and \"-\" characters","startedAt":"2017-02-13T23:11:22Z","lastAt":"2017-02-19T18:59:58Z","messageCount":5,"participants":["Vanderhoof, Tzadik","Duy Nguyen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"311467","messageId":"2C8817BDA27E034F8E9A669458E375EF11886C5A@APSWP0428.ms.ds.uhc.com","threadId":"45132","inReplyTo":null,"subject":"new git-diff switch to eliminate leading \"+\" and \"-\" characters","fromName":"Vanderhoof, Tzadik","fromEmail":"tzadik.vanderhoof@optum360.com","sentAt":"2017-02-13T23:01:41Z","receivedAt":"2017-02-13T23:11:22Z","isPatch":false,"sender":{"key":"tzadik.vanderhoof@optum360.com","avatar":null},"body":"The output of git-diff includes lines beginning with \"+\" and \"-\" to indicate added and deleted lines.  A somewhat common task (at least for me) is to want to copy output from a \"diff\" (usually the deleted lines) and paste it back into my code.\n\nThis is quite inconvenient because of the leading \"+\" and \"-\" characters.  I know there are shell and IDE / editor workarounds but it would be nice if there was a switch to git-diff to make it leave out those characters, especially since \"--color\" kind of makes those leading characters obsolete.\n\nWould it make sense to develop such a switch or has there been work on that already?\n______________________________\nTzadik Vanderhoof | Optum360 \nSr Software Engineer, NLP Innovation\nwww.optum360.com\n\nThis e-mail, including attachments, may include confidential and/or\nproprietary information, and may be used only by the person or entity\nto which it is addressed. If the reader of this e-mail is not the intended\nrecipient or his or her authorized agent, the reader is hereby notified\nthat any dissemination, distribution or copying of this e-mail is\nprohibited. If you have received this e-mail in error, please notify the\nsender by replying to this message and delete this e-mail immediately.\n\n"},{"id":"311895","messageId":"CACsJy8CTL1GUreqNVBYyu2EqqdiUxj-dOOE9=Rr0ivK6-7yKjw@mail.gmail.com","threadId":"45132","inReplyTo":"2C8817BDA27E034F8E9A669458E375EF11886C5A@APSWP0428.ms.ds.uhc.com","subject":"Re: new git-diff switch to eliminate leading \"+\" and \"-\" characters","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-02-17T14:53:50Z","receivedAt":"2017-02-17T14:54:28Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Feb 14, 2017 at 6:01 AM, Vanderhoof, Tzadik\n<tzadik.vanderhoof@optum360.com> wrote:\n> The output of git-diff includes lines beginning with \"+\" and \"-\" to indicate added and deleted lines.  A somewhat common task (at least for me) is to want to copy output from a \"diff\" (usually the deleted lines) and paste it back into my code.\n>\n> This is quite inconvenient because of the leading \"+\" and \"-\" characters.  I know there are shell and IDE / editor workarounds but it would be nice if there was a switch to git-diff to make it leave out those characters, especially since \"--color\" kind of makes those leading characters obsolete.\n\nColor wouldn't show you new/old empty lines though (unless you use\ndifferent background color, but I doubt that looks readable).\n\n> Would it make sense to develop such a switch or has there been work on that already?\n\nI face this \"problem\" every day, but most editors nowadays have\nblock-based editing that would allow you to remove a column of \"+/-\"\neasily. At least it has not bothered me to think of improving it.\n-- \nDuy\n"},{"id":"311898","messageId":"2C8817BDA27E034F8E9A669458E375EF11888CB3@APSWP0428.ms.ds.uhc.com","threadId":"45132","inReplyTo":"CACsJy8CTL1GUreqNVBYyu2EqqdiUxj-dOOE9=Rr0ivK6-7yKjw@mail.gmail.com","subject":"RE: new git-diff switch to eliminate leading \"+\" and \"-\" characters","fromName":"Vanderhoof, Tzadik","fromEmail":"tzadik.vanderhoof@optum360.com","sentAt":"2017-02-17T16:04:20Z","receivedAt":"2017-02-17T16:04:28Z","isPatch":false,"sender":{"key":"tzadik.vanderhoof@optum360.com","avatar":null},"body":"> From: Duy Nguyen [mailto:pclouds@gmail.com]\n> Sent: Friday, February 17, 2017 6:54 AM\n> To: Vanderhoof, Tzadik\n> Cc: git@vger.kernel.org\n> \n> On Tue, Feb 14, 2017 at 6:01 AM, Vanderhoof, Tzadik\n> <tzadik.vanderhoof@optum360.com> wrote:\n> > The output of git-diff includes lines beginning with \"+\" and \"-\" to indicate\n> added and deleted lines.  A somewhat common task (at least for me) is to\n> want to copy output from a \"diff\" (usually the deleted lines) and paste it back\n> into my code.\n> >\n> > This is quite inconvenient because of the leading \"+\" and \"-\" characters.  I\n> know there are shell and IDE / editor workarounds but it would be nice if\n> there was a switch to git-diff to make it leave out those characters, especially\n> since \"--color\" kind of makes those leading characters obsolete.\n> \n> Color wouldn't show you new/old empty lines though (unless you use\n> different background color, but I doubt that looks readable).\n> \n> > Would it make sense to develop such a switch or has there been work on\n> that already?\n> \n> I face this \"problem\" every day, but most editors nowadays have block-\n> based editing that would allow you to remove a column of \"+/-\"\n> easily. At least it has not bothered me to think of improving it.\n\nWould a patch be welcome?\n\nTzadik\n\n> --\n> Duy\n\n\nThis e-mail, including attachments, may include confidential and/or\nproprietary information, and may be used only by the person or entity\nto which it is addressed. If the reader of this e-mail is not the intended\nrecipient or his or her authorized agent, the reader is hereby notified\nthat any dissemination, distribution or copying of this e-mail is\nprohibited. If you have received this e-mail in error, please notify the\nsender by replying to this message and delete this e-mail immediately.\n"},{"id":"311899","messageId":"2C8817BDA27E034F8E9A669458E375EF11888CC1@APSWP0428.ms.ds.uhc.com","threadId":"45132","inReplyTo":"CACsJy8CTL1GUreqNVBYyu2EqqdiUxj-dOOE9=Rr0ivK6-7yKjw@mail.gmail.com","subject":"RE: new git-diff switch to eliminate leading \"+\" and \"-\" characters","fromName":"Vanderhoof, Tzadik","fromEmail":"tzadik.vanderhoof@optum360.com","sentAt":"2017-02-17T16:06:19Z","receivedAt":"2017-02-17T16:06:32Z","isPatch":false,"sender":{"key":"tzadik.vanderhoof@optum360.com","avatar":null},"body":"> From: Duy Nguyen [mailto:pclouds@gmail.com]\n> Sent: Friday, February 17, 2017 6:54 AM\n> To: Vanderhoof, Tzadik\n> Cc: git@vger.kernel.org\n> \n> > Would it make sense to develop such a switch or has there been work on\n> that already?\n> \n> I face this \"problem\" every day, but most editors nowadays have block-\n> based editing that would allow you to remove a column of \"+/-\"\n> easily. At least it has not bothered me to think of improving it.\n\nWould a patch be welcome?\n\nTzadik\n\n> --\n> Duy\n\n\nThis e-mail, including attachments, may include confidential and/or\nproprietary information, and may be used only by the person or entity\nto which it is addressed. If the reader of this e-mail is not the intended\nrecipient or his or her authorized agent, the reader is hereby notified\nthat any dissemination, distribution or copying of this e-mail is\nprohibited. If you have received this e-mail in error, please notify the\nsender by replying to this message and delete this e-mail immediately.\n"},{"id":"312086","messageId":"xmqq60k6m2fu.fsf@gitster.mtv.corp.google.com","threadId":"45132","inReplyTo":"2C8817BDA27E034F8E9A669458E375EF11888CC1@APSWP0428.ms.ds.uhc.com","subject":"Re: new git-diff switch to eliminate leading \"+\" and \"-\" characters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-02-19T18:59:49Z","receivedAt":"2017-02-19T18:59:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Vanderhoof, Tzadik\" <tzadik.vanderhoof@optum360.com> writes:\n\n>> From: Duy Nguyen [mailto:pclouds@gmail.com]\n>> \n>> I face this \"problem\" every day, but most editors nowadays have block-\n>> based editing that would allow you to remove a column of \"+/-\"\n>> easily. At least it has not bothered me to think of improving it.\n>\n> Would a patch be welcome?\n\nI am not enthused for at least two reasons.  \n\nThe weaker one is \"it would likely to introduce a lot of noise in\nthe code for a feature of dubious merit\".  \n\nThe other is a bit more serious.  Cutting and pasting has been a\nsource of lost or mangled whitespaces.  Tabs get expanded, a wrapped\nlong single line turns into two lines, an originally indented line\nauto-indented when inserted to the receiving editor, etc., etc.,\ndepending on the pager that the output was passed through for the\nterminal, the terminal program itself and the editor.  The \"feature\"\nwill encourage cut-and-paste, and I personally would be reluctant to\nadd things that encourage bad practice to the users.\n\nAs Duy said, saving the \"diff\" output to another file, opening in an\neditor that output file and the file the patch targets to modify,\nand transferring the lines while dropping unnecessray parts (i.e.\nunwanted context lines and preimage lines, and possibly undesired\npostimage lines, and also the leading SP/+/- designators) has no\nsuch downside.  It obviously has an added benefit that it makes it\nless likely for people to cut and paste a line and then become\nunsure if they really cut from the green line or they by mistake\nalso pasted an adjacent red line.\n\nSo, I'd say the answer is \"probably not\".\n"}]}