4 ms·
This is an excellent comment and one should also note that the claim is wrong. If one line is changed "a diff" will likely have two lines: one removed, one adde
by gnulinux 3y ago
This is an excellent comment and one should also note that the claim is wrong. If one line is changed "a diff" will likely have two lines: one removed, one added. If you change a sentence "I am studying tonight" to "I am not studying tonight" git diff will show one line deleted when I actually didn't delete anything, conceptually.
- eadler 3y ago`git diff --word-diff` is wonderful for this diff --git 1/old 2/new index 7164d6e..61a276c 100644 --- 1/old +++ 2/new @@ -1 +1 @@ I am {+not+} studying tonight
- yardstick 3y agoWow, why isn’t this the default?!
- _ikke_ 3y agogit diff by default outputs valid patch files that you can feed to patch out git apply. --word-diff does not Kernel development involves working with patches a lot, so it made sense to default to that, and --word-diff was added later anyway.
- yardstick 3y agoAh, makes sense, thanks for the explanation. I’ll have to create an alias for my use!
- dietrichepp 3y ago> This is an excellent comment and one should also note that the claim is wrong. I’ll pretend that this isn’t pedantry. I can understand why you’d say this, but I think you just haven’t explored the way that git diff works, including the configuration options it takes. $ git diff 'HEAD^' diff --git a/file b/file index efb8e76..ca03496 100644 --- a/file +++ b/file @@ -1,3 +1,3 @@ This is context. -I am studying tonight. +I am not studying tonight. This is also context. Try it with --word-diff… $ git diff 'HEAD^' --word-diff diff --git a/file b/file index efb8e76..ca03496 100644 --- a/file +++ b/file @@ -1,3 +1,3 @@ This is context. I am {+not+} studying tonight. This is also context.
- mkesper 3y agoYou can also specify format knowing about languages: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header https://git-scm.com/docs/gitattributes#_defining_a_custom_hu... Or even whole diff converters.