Skip to content

Instantly share code, notes, and snippets.

@dantesun
Created December 3, 2013 10:20
Show Gist options
  • Save dantesun/7767015 to your computer and use it in GitHub Desktop.
Save dantesun/7767015 to your computer and use it in GitHub Desktop.
Create git repository with C/C++ files only and create tags
#!/bin/bash
DIR="$PWD"
GIT="/usr/bin/git"
echo "Generating tags in $DIR"
FILE_LIST=cscope.files
TAG_FILE=tags
if ! [ -d .git ]; then
echo "create Git repository"
$GIT init
echo "Add ignore rule"
cat > .gitignore <<__EOF
#Ignore everything
*
#Except directory
!*/
#But always ignore the following directories
ut/
#And includes the following files
!*.c++
!*.cc
!*.cp
!*.cpp
!*.cxx
!*.h
!*.h++
!*.hh
!*.hp
!*.hpp
!*.hxx
!*.C
!*.H
!*.c
__EOF
fi
function cost()
{
/usr/bin/time -f "...%E elapsed." $*
}
rm -rf cscope.*
rm -rf $TAG_FILE
$GIT add ./\*
$GIT commit -am "DONT CARE" > /dev/null
$GIT ls-files > $FILE_LIST
wc -l $FILE_LIST
echo "Create cscope database"
cost cscope -b -q
echo "Create ctags"
cost ctags -f $TAG_FILE --sort=yes --c++-kinds=+xp --fields=+iaS --extra=+q -L $FILE_LIST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment