Skip to content

Instantly share code, notes, and snippets.

@thangdc94
Forked from xkr47/cvsignore2git.sh
Created June 16, 2017 11:10
Show Gist options
  • Save thangdc94/6fae05c24ddd4fdcddd652d33c302a3c to your computer and use it in GitHub Desktop.
Save thangdc94/6fae05c24ddd4fdcddd652d33c302a3c to your computer and use it in GitHub Desktop.
cvsignore -> gitignore converter
#!/bin/sh
if [ ! -d .git ]; then
echo ERROR: Please run this in the root of the git repository
exit 1
fi
cat > .gitignore <<'EOF'
# CVS global ignores
RCS
SCCS
CVS
CVS.adm
RCSLOG
cvslog.*
tags
TAGS
.make.state
.nse_depinfo
*~
#*
.#*
,*
_$*
*$
*.old
*.bak
*.BAK
*.orig
*.rej
.del-*
*.a
*.olb
*.o
*.obj
*.so
*.exe
*.Z
*.elc
*.ln
core
EOF
split_cvsignore_line () {
perl -pe 's!^\s+!!;s!\s+!\n!g;'
}
if [ -r $HOME/.cvsignore -o "$CVSIGNORE" ]; then
echo '# User global ignores'
[ -r $HOME/.cvsignore ] && cat $HOME/.cvsignore | split_cvsignore_line
[ "$CVSIGNORE" ] && echo "$CVSIGNORE" | split_cvsignore_line
echo
fi >> .gitignore
echo '# Project ignores (converted from .cvsignore files)' >> .gitignore
find -name .cvsignore | while read f ; do
dir="$(dirname "$f" | sed -r 's:^\.::')"
cat "$f" | split_cvsignore_line | awk '{print "'"$dir"'/"$1}' >> .gitignore
git rm -f "$f"
done
git add .gitignore
git commit -m 'Automatically converted .cvsignore files to .gitignore'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment