Skip to content

Instantly share code, notes, and snippets.

@iegik
Forked from luisfaceira/converter.sh
Last active November 14, 2024 14:27
Show Gist options
  • 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
@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