nvim: autoload/git: Fix git log when current branch is master/main
This commit is contained in:
parent
4edfa99a21
commit
da5671b5ae
1 changed files with 10 additions and 2 deletions
|
@ -47,9 +47,13 @@ endfunction
|
||||||
function! git#git_branch_log() abort
|
function! git#git_branch_log() abort
|
||||||
let line = trim(getline('.'))
|
let line = trim(getline('.'))
|
||||||
let branch = split(line, "/")
|
let branch = split(line, "/")
|
||||||
|
let current = trim(system('git branch --show-current'))
|
||||||
" Close the buffer opened by Git branch -a
|
" Close the buffer opened by Git branch -a
|
||||||
silent execute "bw"
|
silent execute "bw"
|
||||||
if len(branch) == 1
|
if current == "master" || current == "main"
|
||||||
|
" Handles the case for checked out main/master branch
|
||||||
|
execute "Git log " . current
|
||||||
|
elseif len(branch) == 1
|
||||||
" Handles the case for local branch
|
" Handles the case for local branch
|
||||||
execute "Git log " . branch[0]
|
execute "Git log " . branch[0]
|
||||||
else
|
else
|
||||||
|
@ -65,9 +69,13 @@ endfunction
|
||||||
function! git#git_branch_log_pretty() abort
|
function! git#git_branch_log_pretty() abort
|
||||||
let line = trim(getline('.'))
|
let line = trim(getline('.'))
|
||||||
let branch = split(line, "/")
|
let branch = split(line, "/")
|
||||||
|
let current = trim(system('git branch --show-current'))
|
||||||
" Close the buffer opened by Git branch -a
|
" Close the buffer opened by Git branch -a
|
||||||
silent execute "bw"
|
silent execute "bw"
|
||||||
if len(branch) == 1
|
if current == "master" || current == "main"
|
||||||
|
" Handles the case for checked out main/master branch
|
||||||
|
execute "Git log " . current
|
||||||
|
elseif len(branch) == 1
|
||||||
" Handles the case for local branch
|
" Handles the case for local branch
|
||||||
execute "Git log --pretty=oneline --no-merges " . branch[0]
|
execute "Git log --pretty=oneline --no-merges " . branch[0]
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue