Git Diff feature request
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
Quoted 8 lines · Nick Gearls
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
Quoted 3 lines · On Fri, Dec 31, 2021 at 11:23 AM <[email protected]> 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
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 ...
Quoted 5 lines · Erik Cervin Edin
Quoted 3 lines · On Fri, Dec 31, 2021 at 11:23 AM<[email protected]> 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
Quoted 2 lines · Nick Gearls
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
bar +0 -0
@@ -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.