[subgit-users-2015] `svn add` and .gitattributes?

81 views
Skip to first unread message

Magnus Therning

unread,
Jun 3, 2016, 3:27:26 PM6/3/16
to subgit...@googlegroups.com
A little while ago I cleaned up the auto-generated .gitattributes
slightly, in particular I removed entries like

<file>.txt -text

and instead put in

* text=auto !eol

*.txt text

I've since noticed that when my svn-using colleagues (on Windows) add
a .txt file .gitattributes gain a line like

<colleagues file>.txt -text

I'd rather not have to regularly clean out these entries, so is there
some way of setting up svn/subgit such that .gitattributes is obeyed
when adding files in SVN?

/M

--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

"Sendmail" and "make" are two well known programs that are pretty widely
regarded as being debugged into existence. That's why their command
languages are so poorly thought out and difficult to learn. It's not
just you -- everyone finds them troublesome.
-- Peter van der Linden, Expert C Programming, p. 220

Magnus Therning

unread,
Jun 3, 2016, 3:28:43 PM6/3/16
to subgit...@googlegroups.com
On Tue, Jan 27, 2015 at 09:20:25PM +0100, Dmitry Pavlenko wrote:
> Hello Magnus,
> Every combination of text/eol/svneol attributes corresponds to
> svn:eol-style/svn:mime-type combination.
>
> If "text" attribute is set and "eol" is set to undef ("!eof"), this
> corresponds to svn:eol-style=native, svn:mime-type unset. So if you
> have
>
> * text !eol
>
> rule in .gitattributes, for SVN files with svn:eol-style=native,
> svn:mime-type unset no additional line will be created; for other
> files (e.g. with svn:eol-style unset) there will be a line
> corresponding to their properties (for svn:eol-style unset, the line
> will have form "path/to/file -text").
> The rule
>
> * text=auto !eol
>
> acts as "* text !eol" for text files and as "* -text !eol" for binary files.
> This means that by adding "*.txt text" rule you changed nothing because "* text=auto" rule already acts as "* text" for text files.
>
>
> So there're 2 ways to solve the problem.
> Solution 1, recommended. Agree with colleagues upon using svn:eol-style=native properties for all text and source code files.
> SubGit/Git users can do nothing in this case because "* text=auto
> !eol" rule already acts for newly added files, that's translated to
> svn:eol-style=native.
> SVN users should set up SVN auto-properties in Subversion config.
> Here's good documentation on that
> http://www.mediawiki.org/wiki/Subversion/auto-props
> In particular, "*.txt = svn:eol-style=native" line in Subversion
> config file would prevent "-text" lines for *.txt files. For other
> text files I also recommend everyone to set up auto-props.

Ah, I was under the impression that my changes to .gitattributes would
be reflected in the SVN properties of files and folders. I'm guessing
I'm wrong.

The UI of SVN properties is terrrible... so is there a way of
converting my beautifully crafted .gitattributes to a series of SVN
calls?

AFAIU, the auto-props have to be set on all existing folders, as well
as added manually to all new folders, right?

/M

--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about.
-- Albert Einstein

Dmitry Pavlenko

unread,
Jun 3, 2016, 3:30:01 PM6/3/16
to subgit...@googlegroups.com
Hello Magnus,
Your changes to .gitattributes are reflected in SVN properties on files and vice versa.
But "*.txt text" addition was no-op change and changed nothing to attributes.
In particular, when you remove

/some/file -text

line from your .gitattributes file, svn:eol-style is automatically set to 'native' on the file in
SVN, because of the first "* text=auto !eol" rule.

>
> The UI of SVN properties is terrrible... so is there a way of
> converting my beautifully crafted .gitattributes to a series of SVN
> calls?

You can checkout the working copy and then call

$ svn propset svn:eol-style native some/file

for every some/file with "-text" attribute. After committing, all "-text" records should disappear
in .gitattributes

But this would solve the problem for already existing file, for newly added files it's important to
setup auto-properties on your colleagues' SVN clients.

>
> AFAIU, the auto-props have to be set on all existing folders, as well
> as added manually to all new folders, right?

'auto-props' are not versioned propreties, they are SVN config-level settings that are specified in
~/.subversion/config file. They are automatically applied every time your colleague adds a new file
to Subversion with

$ svn add some/file

command or with any UI client. They are applied to files only, there's nothing to do with folders.

>
> /M
--
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge

Magnus Therning

unread,
Jun 3, 2016, 3:31:21 PM6/3/16
to subgit...@googlegroups.com
On Thu, Jan 29, 2015 at 05:35:44PM +0100, Dmitry Pavlenko wrote:
[...]

Cutting aggressively in your reply. All the stuff I cut away was
stuff I either didn't know that well before or didn't know at all. In
particular the client config file of SVN is something I've never
looked at before.

>> AFAIU, the auto-props have to be set on all existing folders, as
>> well as added manually to all new folders, right?
>
> 'auto-props' are not versioned propreties, they are SVN config-level
> settings that are specified in ~/.subversion/config file. They are
> automatically applied every time your colleague adds a new file to
> Subversion with
>
> $ svn add some/file
>
> command or with any UI client. They are applied to files only,
> there's nothing to do with folders.

We're talking about different things here apparently. I wasn't aware
of `[auto-props]` in the client config at all. What I'm referring to is
better called svn:auto-props (see
<http://svnbook.red-bean.com/en/1.8/svn.advanced.props.html#svn.advanced.props.ref>).

Any chance of subgit translating (parts of) my nice .gitattributes
into svn:auto-props?

/M

--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

Perl is another example of filling a tiny, short-term need, and then
being a real problem in the longer term.
-- Alan Kay

Dmitry Pavlenko

unread,
Jun 3, 2016, 3:32:39 PM6/3/16
to subgit...@googlegroups.com
Hello Magnus,
Currently SubGit doesn't work with svn:auto-props. Mostly this is because this property appeared only in Subversion 1.8, and older clients do not support that.
But you can set svn:auto-props on your SVN project root manually to

*.txt=svn:eol-style=native
*.java=svn:eol-style=native
...

and so on for all text files with

$ svn co --depth immediates <project_root_URL> wc/
$ svn propedit svn:auto-props wc/
$ svn commit -m "svn:auto-props property set to initialize svn:eol-style to native for text files." wc/

(for *.sh files sometimes it's better to use "*.sh=svn:eol-style=LF" rule) and make sure all your colleagues are using Subversion 1.8.
You do that only once, and the problem will be solved for newly added files (svn:auto-props property is recursive and is applied to files in all subdirectories).
--
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge

Reply all
Reply to author
Forward
0 new messages