Provide checkout --ours/--theirs on X
Closes https://github.com/tpope/vim-fugitive/issues/954
This commit is contained in:
parent
74aefa53ac
commit
01b9a645b6
@ -1407,6 +1407,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
let branch = head
|
let branch = head
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let b:fugitive_status = {'Staged': {}, 'Unstaged': {}}
|
||||||
let [staged, unstaged] = [[], []]
|
let [staged, unstaged] = [[], []]
|
||||||
let i = 0
|
let i = 0
|
||||||
while i < len(output)
|
while i < len(output)
|
||||||
@ -1422,13 +1423,22 @@ function! fugitive#BufReadStatus() abort
|
|||||||
let i += 1
|
let i += 1
|
||||||
endif
|
endif
|
||||||
if line[0] !~# '[ ?!#]'
|
if line[0] !~# '[ ?!#]'
|
||||||
call add(staged, {'type': 'File', 'status': line[0], 'filename': (line[0] =~# '[RC]' ? files : file)})
|
call add(staged, {'type': 'File', 'status': line[0], 'filename': files})
|
||||||
|
let b:fugitive_status['Staged'][files] = line[0]
|
||||||
endif
|
endif
|
||||||
if line[1] !~# '[ !#]'
|
if line[1] !~# '[ !#]'
|
||||||
call add(unstaged, {'type': 'File', 'status': line[1], 'filename': (line[1] =~# '[RC]' ? files : file)})
|
call add(unstaged, {'type': 'File', 'status': line[1], 'filename': files})
|
||||||
|
let b:fugitive_status['Unstaged'][files] = line[1]
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
for dict in staged
|
||||||
|
let b:fugitive_status['Staged'][dict.filename] = dict.status
|
||||||
|
endfor
|
||||||
|
for dict in unstaged
|
||||||
|
let b:fugitive_status['Unstaged'][dict.filename] = dict.status
|
||||||
|
endfor
|
||||||
|
|
||||||
let config = fugitive#Config()
|
let config = fugitive#Config()
|
||||||
|
|
||||||
let pull_type = 'Pull'
|
let pull_type = 'Pull'
|
||||||
@ -2434,6 +2444,13 @@ function! s:StageDelete(lnum, count) abort
|
|||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
endtry
|
endtry
|
||||||
|
elseif a:count == 2
|
||||||
|
call s:TreeChomp('checkout', '--ours', '--', info.paths[0])
|
||||||
|
elseif a:count == 3
|
||||||
|
call s:TreeChomp('checkout', '--theirs', '--', info.paths[0])
|
||||||
|
elseif info.status =~# '[ADU]' &&
|
||||||
|
\ get(b:fugitive_status[info.section ==# 'Staged' ? 'Unstaged' : 'Staged'], info.filename, '') =~# '[AU]'
|
||||||
|
call s:TreeChomp('checkout', info.section ==# 'Staged' ? '--ours' : '--theirs', '--', info.paths[0])
|
||||||
elseif info.status ==# 'U'
|
elseif info.status ==# 'U'
|
||||||
call s:TreeChomp('rm', '--', info.paths[0])
|
call s:TreeChomp('rm', '--', info.paths[0])
|
||||||
elseif info.status ==# 'A'
|
elseif info.status ==# 'A'
|
||||||
|
@ -259,7 +259,10 @@ u Unstage (reset) the file or hunk under the cursor.
|
|||||||
X Discard the change under the cursor. This uses
|
X Discard the change under the cursor. This uses
|
||||||
`checkout` or `clean` under the hood. A command is
|
`checkout` or `clean` under the hood. A command is
|
||||||
echoed that shows how to undo the change. Consult
|
echoed that shows how to undo the change. Consult
|
||||||
`:messages` to see it again.
|
`:messages` to see it again. You can use this during
|
||||||
|
a merge conflict do discard "our" changes (--theirs)
|
||||||
|
in the "Unstaged" section or discard "their" changes
|
||||||
|
(--ours) in the "Staged" section.
|
||||||
|
|
||||||
*fugitive_=*
|
*fugitive_=*
|
||||||
= Toggle an inline diff of the file under the cursor.
|
= Toggle an inline diff of the file under the cursor.
|
||||||
|
Loading…
Reference in New Issue
Block a user