Re: RFC: Using '--no-output-indicator-old' to only show new state
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Mar 10, 2022, 20:40 UTC
- Message-ID
- <CAHk-=wg+n_-btzoyMqnDYsJxFYAyUh0Kb=TkpS8RiD_h3G=_cA@mail.gmail.com>
- In-Reply-To
- <xmqqo82dd0qv.fsf@gitster.g>
On Thu, Mar 10, 2022 at 12:13 PM Junio C Hamano <gitster@pobox.com> wrote:
> > Sounds like the "apply --no-add" in the opposite direction ;-)
I was thinking more the opposite of "--ours/theirs" when merging, but yeah, I guess "--no-add" is technically even closer.
> I would find it handy myself, too, though I tend to read my patches > after applying to my tree so the postimage is usually an invocation > of "less" away for me.
Obviously just looking at the file itself is always an option, and I do that too. But I traditionally do that "grep -v" trick as I'm verifying the patch before sending it out (or before committing) because it's such a nice way to limit the output just to the changed parts.
> I do not think it is a bad idea to have an option to give only the > postimage and another option to give only the preimage. It would > also trivially allow people to show the side-by-side diff in GUI.
I suspect people doing GUI's are happy just parsing the '-' and '+' lines themselves, since they want both sides anyway.
For example, 'gitk' already has that diff/old/new checkbox, that does exactly what my patch does.
And I doubt anybody wants gitk to re-run 'diff' just because somebody clicked another option - it's only used to visualize the diff that was already done differently.
Of course, I might be wrong. I didn't actually look at what 'gitk' does. Maybe it _does_ re-run diff when you click that thing.
But that gitk behavior - which I also do use - is probably the best way to explain the feature. It's just that I also want to get that "New version" behavior for plain "git diff" on the command line.
I don't know what a good command line option would be, though. I'd like it to be somehat short, because the whole point of this is to be a convenience feature.
So "--new/old"? "--pre/post"?
Or it could be something random, and tie it with the existing "-U" option, where "-U+" would be "positive side only", and "-U5-" would be "5 context lines, negative side only". Very dense and convenient, maybe not all that intuitive?
Linus