Comments (3)
Also, the linked Generator appears to not pick up the files in Global and Community
from gitattributes.
What happens if there are then multiple lines of "* text=auto" throughout the file? Does this cause some form of reset of the overrides? Can this generated file actually be used, or do we first need to filter this combined file and remove all duplication?
That is a good point! Let's explore. I made a toy repository with just 2 files:
.gitattributes
test.cpp
git check-attr --all test.cpp
returns what git treats the file as. Here are the results for a given .gitattribute
file:
(git version 2.34.1)
(1)
* text=auto
*.cpp binary
*.cpp text
test.cpp: binary: set
test.cpp: diff: unset
test.cpp: merge: unset
test.cpp: text: set
(2)
*.cpp binary
*.cpp text
* text=auto
test.cpp: binary: set
test.cpp: diff: unset
test.cpp: merge: unset
test.cpp: text: auto
(3)
* text=auto
*.cpp text
*.cpp binary
test.cpp: binary: set
test.cpp: diff: unset
test.cpp: merge: unset
test.cpp: text: unset
(4)
*.cpp text
*.cpp binary
* text=auto
test.cpp: binary: set
test.cpp: diff: unset
test.cpp: merge: unset
test.cpp: text: auto
The results are interesting. It seems like the last entry takes precedence, so text
is either auto
or set
depending on the last entry. But also binary
seems to "win" regardless of where it is. binary
is always set
in the above cases and it even unsets text
when it comes last.
This doesn't look immediately obvious, so a Generator could flatten and deduplicate entries to avoid possible confusion - and have the entry match what git
would have done if all entries where present.
On the other hand, having separate sections for each gitattribute
that you used is very similar to what one would do manually (without a generator) and allows further manual modification and future update because any section would be exactly as you found it from the source.
I think it could go either way (maybe an option?).
Note that the behavior would be easily observable. If binary
is set
, then we get the following with git diff
:
diff --git a/test.cpp b/test.cpp
index cc3f56d..1df2af6 100644
Binary files a/test.cpp and b/test.cpp differ
whereas if it is not set
, then:
diff --git a/test.cpp b/test.cpp
index cc3f56d..1df2af6 100644
--- a/test.cpp
+++ b/test.cpp
@@ -1 +1,2 @@
// blah
+// blah2
Similarly, with customized diff
options, the diff would show the "winning" setting.
from gitattributes.
Also, the linked Generator appears to not pick up the files in Global and Community
You are right. The subfolders are recent additions. The generator(s) have not been updated to take this into account.
from gitattributes.
Related Issues (20)
- Add terraform and hcl files for hashiCorp products
- add markdown in gitattributes HOT 2
- Add WordPress CMS template
- create "gitattributes organization" HOT 9
- Rationale for specifying line endings in `.gitattributes` generally, and specifically for `*.ps1` files. HOT 1
- default config '* text=auto' is placed in multiple templates
- folder ".override/" in gitattributes
- Inconsistent *.pdf attributes HOT 2
- What's the project status? HOT 5
- Consider splitting "Web.gitattributes" into "Jekyll.gitattributes" and "Node.gitattributes" similar to github/gitignore HOT 1
- Use "Global" and "community" folders like github/gitignore HOT 1
- Consider `gh` CLI extension? HOT 3
- Consider removing "*.thing text" from lots of .gitattributes files? HOT 2
- Get in touch with @gitattributes? HOT 10
- Consider clarifying if you can have more than 1 `.gitattributes` file, and how specific the file name(s) need to be... HOT 1
- Directly set a percentage for a specific language in a .gitattributes file. HOT 1
- Unity shadergraph should have eol=LF HOT 1
- What does `diff=astextplain` for `*.epub` accomplish? HOT 2
- Read
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitattributes.