zsh:alias:git-base-branch: Make regexs more robust
Fixes (in order of the patterns that were touched): - Only match `*` that come between BOL and the branch name in brackets, as another branch could be checked out at a commit containing a `*` - Only throw out commits that were committed on our current branch and not those that contain the branch name in the message (e.g. `test`). - Only match until first bracket as the commit message could also contain a pattern like `[.*]` that would be matched instead.
This commit is contained in:
@@ -34,10 +34,10 @@
|
||||
alias gss='git stash'
|
||||
# https://nilansanjaya.wordpress.com/2017/06/02/git-find-base-branch/
|
||||
git_bb='git show-branch -a 2>/dev/null'
|
||||
git_bb+=' | grep "\*"'
|
||||
git_bb+=' | grep -v "$(git rev-parse --abbrev-ref HEAD)"'
|
||||
git_bb+=' | grep "^[^[]*\*"'
|
||||
git_bb+=' | grep -v "^[^[]*\[$(git rev-parse --abbrev-ref HEAD)\]"'
|
||||
git_bb+=' | head -n1'
|
||||
git_bb+=' | sed -E "s/^.*\[([^^~\]*)([~^].*)?\].*$/\1/"'
|
||||
git_bb+=' | sed -E "s/^[^[]*\[([^]~^]*).*$/\1/"'
|
||||
alias git-base-branch="$git_bb"
|
||||
unset git_bb
|
||||
# https://stackoverflow.com/a/1549155
|
||||
|
||||
Reference in New Issue
Block a user