RFC: Using '--no-output-indicator-old' to only show new state

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2022-03-10 19:41:11

So after another round of doing

     git diff | grep -v '^-'

to just show what the end result of a patch is, I decided that there
has to be a better way.

Of course, to normal people, that "better way" is probably some GUI
tool that shows diffs as "before/after" in two different frames next
to each other, but I'm a grumpy old man ("Get off my lawn") and I do
everything but read my email in a standard text-only terminal.

So this RFC is that better way for me.

It's a RFC because maybe people think this is stupid, but even more so
becasue I think it should also go with an actual new and more legible
name - which this tech demonstration does *not* do, because I suspect
people have more opinions on the option name than they have on the
trivial technical parts.

IOW, with this patch, you can do

    git show --no-output-indicator-old

and it shows the diff but without the 'old' lines. That option name is
horrible to write, though, and even with command line completion I
think it migth be worth doing as

   git show --new

or something like that.

When would you want this? The case _I_ tend to use that "grep -v '^-'"
thing is when I re-write a function, and a regular diff really is just
very messy and what I really want to see is just the end result to
verify that "yeah, this looks sane".

In case people care, the immediate (current) cause of this was kernel
commit fe673d3f5bf1 ("mm: gup: make fault_in_safe_writeable() use
fixup_user_fault()"), which really is a fairly messy diff, but what
matters is the much simplified end result of the
fault_in_safe_writeable() function.

But in the commit message, I put a random git commit as an example
instead, just to make it easier to see what's up when you're a git
developer, not a kernel developer.

And hey, there are probably smarter things that could be done: this
doesn't work with word-diffs, for example. Maybe people would want an
equivalent "don't show the deleted word" instead. But this is really
really simple.

And maybe there already was some better way to do this.

Comments?

(And for consistency, this obviously also allows
"--no-output-indicator-new", but I've never found _that_ particularly
useful. But GUI diff tools most certainly also tend to show the old
state on one side, so maybe it's would be reasonable to use as a
"compare the old state vs the new state" in terminals side-by-side. I
just tend to care much more about "what is the end result")

               Linus

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help