Estus Flask
Estus Flask

Reputation: 223259

Files without extensions in .gitattributes

I'm trying to address files without extensions in .gitattributes:

* text=auto
*. eol=lf
.py eol=lf

*. clearly doesn't help. git check-attr --all -- ./foo outputs:

./foo: text: auto

How can this be done?

Upvotes: 5

Views: 2583

Answers (2)

Tim Baverstock
Tim Baverstock

Reputation: 570

This looks like a missing facility in .gitattributes.

In gitignore, you can use the ! operator, as mentioned in How do I add files without dots in them (all extension-less files) to the gitignore file? but gitattributes does not support !.

It's not clear how ! would work in .gitattributes: they may need to add an 'exclude' operation of some sort.

not/valid/yet/* exclude=.

Upvotes: 0

zigarn
zigarn

Reputation: 11625

I think you have to set the value you want to all files, then remove the attribute for files with extension:

* text=auto eol=lf
*.* -eol # or set another default value
*.py eol=lf

It will give the result:

$ git check-attr --all -- file
file: text: auto
file: eol: crlf
$ git check-attr --all -- foo.py
foo.py: text: auto
foo.py: eol: lf
$ git check-attr --all -- bar.txt
bar.txt: text: auto
bar.txt: eol: unset

Upvotes: 6

Related Questions