zsh:alias:git-base-branch: Match merge commits too
Merge commits should also be matched (indicated by a '-') for the case that the base branches last commit is a merge commit and another branch exists that checked out the newest commit that was merged. Example log (from `glog`): ``` * abcdef Foo (HEAD -> feature) * bcdefa Merge branch 'other-feature' into base (base) |\ | * cdefab Bar (other-feature) |/ * ... ... ``` with `git show-branch -a` output like: ``` ! [base] Merge branch 'other-feature' into base * [feature] Foo ! [other-feature] Bar --- * [feature] Foo -- [base] Merge branch 'other-feature' into base +*+ [other-feature] Bar ``` Here we want `base` to be returned instead of `other-feature` and thus '-' needs to be matched as well.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
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 "^[^[]*[*-].*\["'
|
||||
git_bb+=' | grep -v "^[^[]*\[$(git rev-parse --abbrev-ref HEAD)\]"'
|
||||
git_bb+=' | head -n1'
|
||||
git_bb+=' | sed -E "s/^[^[]*\[([^]~^]*).*$/\1/"'
|
||||
|
||||
Reference in New Issue
Block a user