diff --git a/README.md b/README.md index d4d95ad..ef5c249 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ doesn't need to 'learn' anything, and it can do SCM-specific stuff like: The default alias for `git_index` is 'c', which might stand for 'code' -You will first need to configure your repository directory by setting `GIT_REPO_DIR` in `~/.git.sbmrc`. +You will first need to configure your repository directory by setting `GIT_REPO_DIR` in `~/.git.scmbrc`. Then, build the index: diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index dc21a57..0a195f2 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -17,7 +17,7 @@ function _scmb_git_branch_shortcuts { # Fall back to normal git branch, if any unknown args given if [[ "$($_git_cmd branch | wc -l)" -gt 300 ]] || ([[ -n "$@" ]] && [[ "$@" != "-a" ]]); then exec_scmb_expand_args $_git_cmd branch "$@" - return 1 + return $? fi # Use ruby to inject numbers into git branch output diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index 4ec8dd1..fa60797 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -171,7 +171,7 @@ function is_git_dirty { [[ $($GIT_BINARY status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" } function parse_git_branch { - $GIT_BINARY branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/" + git rev-parse --abbrev-ref HEAD 2> /dev/null } # If the working directory is clean, update the git repository. Otherwise, show changes. diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index 51611db..7b27e66 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -88,7 +88,7 @@ puts "%s#%s On branch: %s#{@branch}#{difference}%s %s| [%s*%s]%s => $#{ENV["gi ] def has_modules? - @has_modules ||= File.exists?(File.join(@project_root, '.gitmodules')) + @has_modules ||= File.exist?(File.join(@project_root, '.gitmodules')) end # Index modification states 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