git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff --functional-changes ?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 22, 2022, 15:53 UTC
Message-ID
<5s05s44n-6q71-1198-8or9-164637q1sqp4@tzk.qr>
In-Reply-To
<CAOu2uD_CaVxxEtZhe4197ERDFASckUBtK_NyhmwQXr=5_reSXw@mail.gmail.com>
Hi Christian,
On Fri, 19 Aug 2022, Christian Heller wrote:
Show 12 quoted lines
> Feature request
>
> I recently ran GNU indent on a larger C project which made all diffs
> horribly noisy.
> Is there an option for git diff to ignore changes due to the placement
> of curly braces '{', '}' ?
> Equally helpful would be an option to ignore changes to comments.
>
> Something like:
> - delete all comments
> - re-normalize line-breaks and indentation
> - show only 'functional' changes

This would be very language-specific, and if you find a utility that can do that, you will want to use it in Git via the external diff extension mechanism: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---ext-diff

As far as pure Git goes, I have had luck using the [--ignore-space-change][space-change] and the [--word-diff][word-diff] options.

To be honest, I use a custom word diff quite often: `--word-diff=[A-Za-z0-9_]+|.`. This marks stretches of alpha-numeric-plus-underscore characters as words, and treats all other characters as single-character words, too (which means that it also colors parentheses and such).

Maybe these help you, even if they do not solve precisely for what you asked.

Ciao, Johannes

[space-change]: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---ignore-space-change [word-diff]: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---word-diffltmodegt

Previous: Christian Heller
Message 2 of 2 in “git diff --functional-changes ?”
  1. Christian HellerAug 19, 2022
  2. Johannes SchindelinAug 22, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.