diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index 54b3191..a8616ce 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -209,7 +209,7 @@ theirs(){ _git_resolve_merge_conflict "their" "$@"; } # * Execute prerequisite commands if message given, abort if not # * Pipe commit message to 'git commit' # * Add escaped commit command and unescaped message to bash history. -git_commit_prompt() { +git_commit_prompt() ( local commit_msg local saved_commit_msg if [ -f "/tmp/.git_commit_message~" ]; then @@ -268,10 +268,10 @@ git_commit_prompt() { # Delete saved commit message if commit was successful rm -f "/tmp/.git_commit_message~" fi -} +) # Prompt for commit message, then commit all modified and untracked files. -git_commit_all() { +git_commit_all() ( fail_if_not_git_repo || return 1 changes=$(git status --porcelain | wc -l | tr -d ' ') if [ "$changes" -gt 0 ]; then @@ -283,10 +283,10 @@ git_commit_all() { else echo "# No changed files to commit." fi -} +) # Add paths or expanded args if any given, then commit all staged changes. -git_add_and_commit() { +git_add_and_commit() ( fail_if_not_git_repo || return 1 git_silent_add_shortcuts "$@" changes=$(git diff --cached --numstat | wc -l) @@ -296,4 +296,4 @@ git_add_and_commit() { else echo "# No staged changes to commit." fi -} +) diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..e69de29