From 136fb6b4ee446fff8bd976768702200460714c96 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 29 Oct 2022 15:12:06 +1300 Subject: [PATCH 1/5] Define git functions with parentheses instead of curly braces, so that we can press Ctrl+C to quit the commit prompt without terminating the shell session. (Parentheses run the function in a subshell.) --- lib/git/status_shortcuts.sh | 12 ++++++------ test.sh | 0 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 test.sh 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 From 0e21e89f3a32c9967f84a3b2ace761544094e9de Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Thu, 17 Nov 2022 02:27:46 +1300 Subject: [PATCH 2/5] Speed up and simplify parse_git_branch --- lib/git/repo_index.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From ae2dd1a559139e8e294e649278b07e3dc497bfcd Mon Sep 17 00:00:00 2001 From: Kimmo Brunfeldt <1232405+kimmobrunfeldt@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:43:16 +0200 Subject: [PATCH 3/5] Use File.exist over deprecated File.exists --- lib/git/status_shortcuts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 57e6d583f7dc1ec58e678c14bf185870605d2d87 Mon Sep 17 00:00:00 2001 From: mike crockett Date: Thu, 19 Jan 2023 08:17:05 -0600 Subject: [PATCH 4/5] Return error code from git branch command. --- lib/git/branch_shortcuts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From c12c5e366584c047e00ecdbb52f5112988e6c21e Mon Sep 17 00:00:00 2001 From: Alex Conlin <458604+alexconlin@users.noreply.github.com> Date: Thu, 6 Jul 2023 10:53:03 +0100 Subject: [PATCH 5/5] fix rc file suffix in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: