X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=setup.sh;h=50df24d8ccc5223a5adb6f80b58f6641cc7abc86;hb=222807c8b67d1c3429fc860e7924aa37e8d7d376;hp=e18d62c0f95197712c9fe6eeb98e265b288fb523;hpb=b7ab75a41290728ec465f732d697f136186a4cef;p=config%2Fdotfiles.git diff --git a/setup.sh b/setup.sh index e18d62c..50df24d 100755 --- a/setup.sh +++ b/setup.sh @@ -7,7 +7,7 @@ # Creates a new git repository in $1, adds a new remote named $2 and fetches # the master on $3. If the git repository already exists a new remote $2 for # $3 is added. If the remote already exists nothing happens. -function git_remote_init_update() { +git_remote_init_update() { # Make sure the requested directory exists. mkdir -p "$1" # Go to the target directory. @@ -28,9 +28,10 @@ function git_remote_init_update() { echo "Adding remote '$2' to '$1'." git remote add -t master "$2" "$3/$1" git fetch "$2" > /dev/null - # Remove the remote if the fetch was unsuccessful. + # Remove the remote and abort if the fetch was unsuccessful. if [ "$?" -ne "0" ]; then git remote rm "$2" + exit 1 fi # Pushing to the remote pushes only the master branch in remotes named @@ -43,9 +44,10 @@ function git_remote_init_update() { fi # Merge with remote master if the repository was just created, otherwise - # the repository starts empty. + # the repository starts empty. Also run gc to compress the new repository. if [ $new = yes ]; then git merge "$2/master" + git gc > /dev/null fi # Go back to the starting directory.