# Git Diff feature request

5 messages from 2021-12-30 to 2022-01-03. Participants: Nick Gearls, rsbecker@nexbridge.com, Erik Cervin Edin.
Thread: https://gitlist.dev/t/57166

## Nick Gearls, 2021-12-30 11:33

Subject: Git Diff feature request
Message-ID: <52591f5d-d4b5-90ea-e84e-32b99803a3e6@gmail.com>
URL: https://gitlist.dev/e/52591f5d-d4b5-90ea-e84e-32b99803a3e6%40gmail.com

```
On top of the option ignore-all-space, it would be very handy (for 
several programming languages) to have an additional option 
ignore-all-space-and-eol where the following snippets would be equivalent:

if (...) a = 1

if (...)
    a = 1

Thanks

```

## rsbecker@nexbridge.com, 2021-12-30 12:26

Subject: RE: Git Diff feature request
Message-ID: <00dd01d7fd78$7e69e150$7b3da3f0$@nexbridge.com>
URL: https://gitlist.dev/e/00dd01d7fd78%247e69e150%247b3da3f0%24%40nexbridge.com
In-Reply-To: <52591f5d-d4b5-90ea-e84e-32b99803a3e6@gmail.com>

```
On December 30, 2021 6:33 AM, Nick Gearls wrote:
> On top of the option ignore-all-space, it would be very handy (for several
> programming languages) to have an additional option ignore-all-space-and-
> eol where the following snippets would be equivalent:
> 
> if (...) a = 1
> 
> if (...)
>     a = 1

One interesting technique I have seen used is to set up a pre-commit hook and/or clean filter to format code according to corporate/team standards. Reprocessing code prior to the commit would allow a normalization of coding standards and removing of EOL or space/tab concerns. So even if a developer did

if (...) a= 1

By the time it reaches the repo, it looks like

if (...)
    a = 1

We use a similar technique (enforced only by policy right now, not a hook), which is to require code to run through standard IDE source formatting. Improperly formatted code hitting pull requests gets a decline until the code is properly formatted. A pull request diff might not include an above suggested diff option.

--Randall


```

## Erik Cervin Edin, 2021-12-31 11:15

Subject: Re: Git Diff feature request
Message-ID: <CA+JQ7M_tQG4yzSeHjZxPWuWEOM=iSLrWxojQGcpL9E7FcoXLRg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BJQ7M_tQG4yzSeHjZxPWuWEOM%3DiSLrWxojQGcpL9E7FcoXLRg%40mail.gmail.com
In-Reply-To: <00dd01d7fd78$7e69e150$7b3da3f0$@nexbridge.com>

```
On Fri, Dec 31, 2021 at 11:23 AM <rsbecker@nexbridge.com> wrote:
> One interesting technique I have seen used is to set up a pre-commit hook and/or clean filter to format code according to corporate/team standards. Reprocessing code prior to the commit would allow a normalization of coding standards and removing of EOL or space/tab concerns.
> ...
> We use a similar technique (enforced only by policy right now, not a hook), which is to require code to run through standard IDE source formatting. Improperly formatted code hitting pull requests gets a decline until the code is properly formatted.

I agree with Randall, the easiest solution is to adhere to a formatting standard

```

## Nick Gearls, 2022-01-03 07:53

Subject: Re: Git Diff feature request
Message-ID: <e3e2cf38-31e0-7b3e-af79-88226dcdabe5@gmail.com>
URL: https://gitlist.dev/e/e3e2cf38-31e0-7b3e-af79-88226dcdabe5%40gmail.com
In-Reply-To: <CA+JQ7M_tQG4yzSeHjZxPWuWEOM=iSLrWxojQGcpL9E7FcoXLRg@mail.gmail.com>

```
When you want to compare 2 versions of a repo you don't own, you don't 
have the option to apply a formatting standard ...

On 31-12-2021 12:15, Erik Cervin Edin wrote:
> On Fri, Dec 31, 2021 at 11:23 AM<rsbecker@nexbridge.com>  wrote:
>> One interesting technique I have seen used is to set up a pre-commit hook and/or clean filter to format code according to corporate/team standards. Reprocessing code prior to the commit would allow a normalization of coding standards and removing of EOL or space/tab concerns.
>> ...
>> We use a similar technique (enforced only by policy right now, not a hook), which is to require code to run through standard IDE source formatting. Improperly formatted code hitting pull requests gets a decline until the code is properly formatted.
> I agree with Randall, the easiest solution is to adhere to a formatting standard


```

## Erik Cervin Edin, 2022-01-03 10:14

Subject: Re: Git Diff feature request
Message-ID: <CA+JQ7M-3sswuYzuXy+bs=e26o3btDoK9z3A0j4WVvELoHG5A-Q@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BJQ7M-3sswuYzuXy%2Bbs%3De26o3btDoK9z3A0j4WVvELoHG5A-Q%40mail.gmail.com
In-Reply-To: <83d398ce-caba-34f7-3727-3e7f5d396127@gmail.com>

```
On Mon, Jan 3, 2022 at 8:43 AM Nick Gearls <nickgearls@gmail.com> wrote:
>
> When you want to compare 2 versions of a repo you don't own, you don't have the option to apply a formatting standard ...

You may try
https://git-scm.com/docs/diff-options#Documentation/diff-options.txt---word-diff-regexltregexgt

  printf 'if (xyz) biz()\n' > bar
  git commit -m 1 bar
  printf 'if (xyz)\n  biz()\n' > bar
  git commit -m 2 bar
  git diff --word-diff-regex='[^[:space:]]' HEAD~

yields a diff with differences hidden

diff --git a/bar b/bar
index 49d380e..05c8e60 100644
--- a/bar
+++ b/bar
@@ -1 +1,2 @@
if (xyz)
  biz()

But from gits perspective, the files are different and the lines are different.
This is the reason having an adhering to a formatting standard is advised,
and something IMHO every serious project should adhere to.

```
