Skip to content

Commit

Permalink
plaugin/magit.vim: output an understandable message when user tries o…
Browse files Browse the repository at this point in the history
…t discard an untracked file (fix #58)
  • Loading branch information
jreybert committed Feb 9, 2016
1 parent 826432e commit cf89410
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,21 @@ function! s:mg_stage_closed_file(discard)
endif
else
if ( section == 'unstaged' )
call magit#git#git_checkout(magit#utils#add_quotes(filename))
if ( file.status == '?' )
echohl WarningMsg
echomsg "By default, vimagit won't discard "
\ "untracked file (which means delete this file)"
echohl None
return
else
call magit#git#git_checkout(magit#utils#add_quotes(filename))
endif
else
echoerr "Must be in \"" .
\ g:magit_sections.unstaged . "\" section"
echohl WarningMsg
echomsg "Can not discard file in \"" .
\ g:magit_sections.staged . "\" section, "
\ "unstage file first."
echohl None
endif
endif
call magit#update_buffer()
Expand Down

0 comments on commit cf89410

Please sign in to comment.