From 2b6e35d5ebcffe66be578b509c5123c9965507db Mon Sep 17 00:00:00 2001 From: Adam Parkin Date: Tue, 1 Oct 2013 13:26:55 -0700 Subject: [PATCH] Address issue #190, git-setup should test for existing .git in target directory - now exits with an error message if the target directory already has a .git directory --- bin/git-setup | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/git-setup b/bin/git-setup index 9916c7c..c7a35d7 100755 --- a/bin/git-setup +++ b/bin/git-setup @@ -1,8 +1,16 @@ #!/bin/sh +gitdirexists(){ + if [ -d ".git" ]; then + echo ".git directory already exists, aborting" + exit 1 + fi +} + dir=$(test -z "$*" && echo "." || echo "$*") mkdir -p "$dir" \ && cd "$dir" \ + && gitdirexists \ && git init \ && git add . \ && git commit -m 'Initial commit'