git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* new git-diff switch to eliminate leading "+" and "-" characters
@ 2017-02-13 23:01 Vanderhoof, Tzadik
  2017-02-17 14:53 ` Duy Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Vanderhoof, Tzadik @ 2017-02-13 23:01 UTC (permalink / raw)
  To: git@vger.kernel.org

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.

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.

Would it make sense to develop such a switch or has there been work on that already?
______________________________
Tzadik Vanderhoof | Optum360 
Sr Software Engineer, NLP Innovation
www.optum360.com

This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: new git-diff switch to eliminate leading "+" and "-" characters
  2017-02-13 23:01 new git-diff switch to eliminate leading "+" and "-" characters Vanderhoof, Tzadik
@ 2017-02-17 14:53 ` Duy Nguyen
  2017-02-17 16:04   ` Vanderhoof, Tzadik
  2017-02-17 16:06   ` Vanderhoof, Tzadik
  0 siblings, 2 replies; 5+ messages in thread
From: Duy Nguyen @ 2017-02-17 14:53 UTC (permalink / raw)
  To: Vanderhoof, Tzadik; +Cc: git@vger.kernel.org

On Tue, Feb 14, 2017 at 6:01 AM, Vanderhoof, Tzadik
<tzadik.vanderhoof@optum360.com> wrote:
> 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.
>
> 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.

Color wouldn't show you new/old empty lines though (unless you use
different background color, but I doubt that looks readable).

> Would it make sense to develop such a switch or has there been work on that already?

I face this "problem" every day, but most editors nowadays have
block-based editing that would allow you to remove a column of "+/-"
easily. At least it has not bothered me to think of improving it.
-- 
Duy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: new git-diff switch to eliminate leading "+" and "-" characters
  2017-02-17 14:53 ` Duy Nguyen
@ 2017-02-17 16:04   ` Vanderhoof, Tzadik
  2017-02-17 16:06   ` Vanderhoof, Tzadik
  1 sibling, 0 replies; 5+ messages in thread
From: Vanderhoof, Tzadik @ 2017-02-17 16:04 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: git@vger.kernel.org

> From: Duy Nguyen [mailto:pclouds@gmail.com]
> Sent: Friday, February 17, 2017 6:54 AM
> To: Vanderhoof, Tzadik
> Cc: git@vger.kernel.org
> 
> On Tue, Feb 14, 2017 at 6:01 AM, Vanderhoof, Tzadik
> <tzadik.vanderhoof@optum360.com> wrote:
> > 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.
> >
> > 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.
> 
> Color wouldn't show you new/old empty lines though (unless you use
> different background color, but I doubt that looks readable).
> 
> > Would it make sense to develop such a switch or has there been work on
> that already?
> 
> I face this "problem" every day, but most editors nowadays have block-
> based editing that would allow you to remove a column of "+/-"
> easily. At least it has not bothered me to think of improving it.

Would a patch be welcome?

Tzadik

> --
> Duy


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: new git-diff switch to eliminate leading "+" and "-" characters
  2017-02-17 14:53 ` Duy Nguyen
  2017-02-17 16:04   ` Vanderhoof, Tzadik
@ 2017-02-17 16:06   ` Vanderhoof, Tzadik
  2017-02-19 18:59     ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Vanderhoof, Tzadik @ 2017-02-17 16:06 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: git@vger.kernel.org

> From: Duy Nguyen [mailto:pclouds@gmail.com]
> Sent: Friday, February 17, 2017 6:54 AM
> To: Vanderhoof, Tzadik
> Cc: git@vger.kernel.org
> 
> > Would it make sense to develop such a switch or has there been work on
> that already?
> 
> I face this "problem" every day, but most editors nowadays have block-
> based editing that would allow you to remove a column of "+/-"
> easily. At least it has not bothered me to think of improving it.

Would a patch be welcome?

Tzadik

> --
> Duy


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: new git-diff switch to eliminate leading "+" and "-" characters
  2017-02-17 16:06   ` Vanderhoof, Tzadik
@ 2017-02-19 18:59     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2017-02-19 18:59 UTC (permalink / raw)
  To: Vanderhoof, Tzadik; +Cc: Duy Nguyen, git@vger.kernel.org

"Vanderhoof, Tzadik" <tzadik.vanderhoof@optum360.com> writes:

>> From: Duy Nguyen [mailto:pclouds@gmail.com]
>> 
>> I face this "problem" every day, but most editors nowadays have block-
>> based editing that would allow you to remove a column of "+/-"
>> easily. At least it has not bothered me to think of improving it.
>
> Would a patch be welcome?

I am not enthused for at least two reasons.  

The weaker one is "it would likely to introduce a lot of noise in
the code for a feature of dubious merit".  

The other is a bit more serious.  Cutting and pasting has been a
source of lost or mangled whitespaces.  Tabs get expanded, a wrapped
long single line turns into two lines, an originally indented line
auto-indented when inserted to the receiving editor, etc., etc.,
depending on the pager that the output was passed through for the
terminal, the terminal program itself and the editor.  The "feature"
will encourage cut-and-paste, and I personally would be reluctant to
add things that encourage bad practice to the users.

As Duy said, saving the "diff" output to another file, opening in an
editor that output file and the file the patch targets to modify,
and transferring the lines while dropping unnecessray parts (i.e.
unwanted context lines and preimage lines, and possibly undesired
postimage lines, and also the leading SP/+/- designators) has no
such downside.  It obviously has an added benefit that it makes it
less likely for people to cut and paste a line and then become
unsure if they really cut from the green line or they by mistake
also pasted an adjacent red line.

So, I'd say the answer is "probably not".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-19 18:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-13 23:01 new git-diff switch to eliminate leading "+" and "-" characters Vanderhoof, Tzadik
2017-02-17 14:53 ` Duy Nguyen
2017-02-17 16:04   ` Vanderhoof, Tzadik
2017-02-17 16:06   ` Vanderhoof, Tzadik
2017-02-19 18:59     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).