Skip to content

Instantly share code, notes, and snippets.

@iegik
Forked from luisfaceira/converter.sh
Last active November 6, 2021 05:23
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save iegik/3450385 to your computer and use it in GitHub Desktop.
Save iegik/3450385 to your computer and use it in GitHub Desktop.
Oneliner to convert svn:ignore into .gitignore
#!/bin/bash
cat .gitignore | sed 's/^/\.\//g;s/\(.*\)\/\([0-9a-zA-Z\*\?\.]*\)$/svn propedit svn:ignore "\2" \1 /mg' | bash
#!/bin/bash
svn propget -R svn:ignore | grep -v "^$" | sed "s/\(\(.*\) - \)\(.*\)/\2\/\3/g" | sort -u >> .gitignore
@sanjay-russmediatech
Copy link

really helpful

@svendhhh
Copy link

svendhhh commented Aug 11, 2017

Can I suggest adding a -u to the sort of svnignore2gitignore.sh to remove duplicates?
(I'm not sure why there'd be duplicates in the SVN ignore, or if could make sense there, but I'm pretty sure it doesn't make sense in .gitignore)?
I found out why I had duplicates. I had the "root" of the SVN project checked out, so was getting some entries for all branches/tags as well as root, and some duplicates that way... might not be any use to add the -u after all?

@iegik
Copy link
Author

iegik commented Jun 22, 2018

@svendhhh Sure. Thanks!

@r-eis
Copy link

r-eis commented Mar 18, 2020

Nice script, but I think it does not handle the case of an svn:ignore property with multiple entries correctly. These are stored with a line break as a separator in the property value, see the following example:

File system with one folder and two individually ignored files:

a-folder-with-two-svnignore-entries/file1
a-folder-with-two-svnignore-entries/file2

Output of svn propget svn:ignore:

a-folder-with-two-svnignore-entries - file1
file2

Would result in the following .gitignore:

a-folder-with-two-svnignore-entries/file1
file2

So file2 is incorrectly considered as a global ignore.

Do you have an idea of how to handle this in a one-liner?

@iegik
Copy link
Author

iegik commented Mar 19, 2020

@r-eis I have no suggestions, but You may research this question and advise some changes.
This script was created for one reason - to not do a lot by hands :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment