]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adding --config option to commit script
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 15 Jan 2013 19:27:19 +0000 (17:27 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 15 Jan 2013 19:27:19 +0000 (17:27 -0200)
commit

diff --git a/commit b/commit
index 03e9a8a56ed9317c02714cdd239bcaf2363c4b62..3cf9980f646846235ef06335ad79e6f27273944a 100755 (executable)
--- a/commit
+++ b/commit
@@ -3,6 +3,9 @@
 # Commit both on git and svn
 #
 
+# Parameters
+ARGS="$*"
+
 # Check if a file is inside a git repository
 # Usage: git_folder <file>
 function git_folder {
@@ -84,24 +87,35 @@ function git_push {
 # Check user information
 function git_user {
   if ! grep -q "^\[user\]" $GIT_FOLDER/.git/config; then
-    echo "No user configuration section found in the repository."
-    echo "This might be a privacy issue"
-
-   if [ -e "$HOME/.gitconfig" ]; then
-     echo "You should try to use your default setting:"
-     if [ "$GIT_FOLDER" == "$(pwd)" ]; then
-       echo "cat <<EOF >> .git/config"
-     else
-       echo "cat <<EOF >> $GIT_FOLDER/.git/config"
-     fi
-     grep -A 2 "^\[user\]" $HOME/.gitconfig
-     echo "EOF"
-   fi
-
-    exit 1
+    if echo $ARGS | grep -q '--config'; then
+      grep -A 2 "^\[user\]" $HOME/.gitconfig >> $GIT_FOLDER/.git/config
+    else
+
+      echo "No user configuration section found in the repository."
+      echo "This might be a privacy issue"
+      echo ""
+
+      if [ -e "$HOME/.gitconfig" ]; then
+        echo "You should try to use your default setting:"
+        if [ "$GIT_FOLDER" == "$(pwd)" ]; then
+          echo "cat <<EOF >> .git/config"
+        else
+          echo "cat <<EOF >> $GIT_FOLDER/.git/config"
+        fi
+        grep -A 2 "^\[user\]" $HOME/.gitconfig
+        echo "EOF"
+
+        echo ""
+        echo "Use --config if you want these lines to be added at .git/config"
+      fi
+
+      exit 1
+
+    fi
   fi
 }
 
+# Main
 if [ ! -z "$1" ]; then
   if is_svn .; then
     svn commit -m "$*"