Skip to content

Commit

Permalink
.gitattributes: Prevent line ending conversion (microsoft#809)
Browse files Browse the repository at this point in the history
## Description

Unsets the text attribute on all files to prevent their line endings
from being normalized.

See https://git-scm.com/docs/gitattributes for background.

This was previously accomplished solely by instructing users to set
core.autocrlf to false. However, that does not translate to pipelines
and setting in a pipeline requires the system level git configuration
to be modified prior to checkout. Git configs cannot be checked into
to a repo and automatically used for security reasons.

This is a simple way to check the change into the repo so it applies
for all users including pipelines to prevent line ending conversion.

This allows plugins like LineEndingCheck to produce similar results
in pipelines on Linux and Windows agents.

---

**This commit is testing the change for a period of time in the
mu_basecore repo**.

If no issues with git operations and impact on tools is discovered
after a couple weeks, it will be synced across all repos from
mu_devops.

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

- Clone mu_basecore repo with the change locally and verify a new file
added
with several commits of changes appears properly in git unified diffs
like
  those from git format-patch, git diff, etc.
- Verify changes on existing files appear as expected in git history.
- Verify pipelines with the change properly preserve line endings so
line ending
  checks (LineEndingCheck plugin) are consistent across agents.

Tested in the following mu_basecore Windows agent pipeline runs:

- [Expect LineEndingCheck
Failure](https://dev.azure.com/projectmu/mu/_build/results?buildId=67237&view=results)
- [Expect LineEndingCheck
Pass](https://dev.azure.com/projectmu/mu/_build/results?buildId=67238&view=results)

Tested in the following mu_basecore Linux agent pipeline runs:

- [Expect LineEndingCheck
Failure](https://dev.azure.com/projectmu/mu/_build/results?buildId=67257&view=results)
- [Expect LineEndingCheck
Pass](https://dev.azure.com/projectmu/mu/_build/results?buildId=67258&view=results)

## Integration Instructions

N/A

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored Apr 12, 2024
1 parent 291b637 commit e2ef21d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text

0 comments on commit e2ef21d

Please sign in to comment.