From 047aa24b29c9355648bdc8633c3face176572adf Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 15 Jan 2013 17:27:19 -0200 Subject: Adding --config option to commit script --- commit | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/commit b/commit index 03e9a8a..3cf9980 100755 --- 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 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 <> .git/config" - else - echo "cat <> $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 <> .git/config" + else + echo "cat <> $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 "$*" -- cgit v1.2.3