line-endings (dos vs. unix text) files in stash/git

Garret Pick December 10, 2012

We are evaluating stash. Our current source control system forces text files in Unix format. It looks like something similar can be done with git via the config command.

http://stackoverflow.com/questions/2466959/git-removing-carriage-returns-from-source-controlled-files

Does stash provide any way of managing this or is there a way to create the repo like this by default?

4 answers

1 accepted

0 votes
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2012

Hi Garret,

Actually I tell a lie. It can be fone via the .gitattributes file.

http://stackoverflow.com/questions/170961/whats-the-best-crlf-handling-strategy-with-git

It would certainly be possible to write a plugin which automatically creates a repository with these settings enabled. There isn't anything on the road map yet, but we will certainly keep it in mind.

Cheers,

Charles

Garret Pick December 11, 2012

Thanks Charles. We were looking at the .gitattributes file also. Things like this are places where I think stash can really add some value for an enterprise git solution. How would we convert this into an actual feature request that folks could vote on, etc?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2012

Hi Garret,

You can raise a STASH Jira, and we can track/vote on the feature request there.

https://jira.atlassian.com/browse/STASH

To write the plugin (or anyone reading this) you could listen for the RepositoryCreatedEvent, and then use GitScmConfig.getRepositoryDir() to find the directory, manually create the attributes file and commit. The 'tricky' part is know when to apply this behaviour. If you always want the same line-endings then you don't have to worry about configuration screens and such.

I hope this helps.

Charles

Garret Pick December 11, 2012

I've created the following

https://jira.atlassian.com/browse/STASH-2912 and referenced this answer.

1 vote
Pavel Baranchikov November 25, 2014

Hi, Garret.

From now, I can suggest you to use stash-eol-check plugin, to force EOL style of new committed changes.

Best regards,

Pavel

1 vote
Semyon Vadishev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2012

Hello Garret,

If you are migrating from Subversion, consider using SVN Importer Plugin for Stash. It converts any SVN repository to Git and keeps all the line ending rules one has enforced for SVN repository (among other things).

You might be interested in this blog post as well, it has a great overview of using .gitattributes file to enforce line endings at Git repository; it also compares Git & SVN techniques of handling EOL bytes.

Hope that helps,

Semyon

Garret Pick December 11, 2012

Hi Seymon,

Thanks for the reply - the blog post is particularly helpful.

Unfortunately, we are not migrating from SVN - but the plugin looks great.

Garret

Semyon Vadishev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2012

Thank you, Garret. Hopefully, my answer is helpful for those who's migrating from SVN to Stash.

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2012

Hi Garret,

Unfortunately line endings can only be enforced per-client with the auto.crlf configuration flag. This setting cannot be embedded in the actual repository by Stash (or any system), only set locally by users.

Sorry about that.

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events