Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vimagit
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
jreybert
vimagit
Commits
aa679e53
Commit
aa679e53
authored
9 years ago
by
Jerome Reybert
Browse files
Options
Downloads
Patches
Plain Diff
plugin/magit.vim: handle empty commit (without staged file) and empty commit message (fix #79)
parent
072cad13
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugin/magit.vim
+33
-7
33 additions, 7 deletions
plugin/magit.vim
with
33 additions
and
7 deletions
plugin/magit.vim
+
33
−
7
View file @
aa679e53
...
...
@@ -372,16 +372,44 @@ function! s:mg_git_commit(mode) abort
silent
let
git_result
=
magit#utils#
system
(
g:magit_git_cmd
.
\
" commit --amend -C HEAD"
)
else
let
commit_flag
=
""
if
(
empty
(
magit#get_staged_files
()
)
)
let
choice
=
confirm
(
\
"Do you really want to commit without any staged files?"
,
\
"&Yes\n&No"
,
2
)
if
(
choice
!=
1
)
return
else
let
commit_flag
.=
" --allow-empty "
endif
endif
let
commit_msg
=
s:mg_get_commit_msg
()
let
amend_flag
=
""
if
(
empty
(
commit_msg
)
)
let
choice
=
confirm
(
\
"Do you really want to commit with an empty message?"
,
\
"&Yes\n&No"
,
2
)
if
(
choice
!=
1
)
return
else
let
commit_flag
.=
" --allow-empty-message "
endif
endif
if
(
a:mode
==
'CA'
)
let
amend
_flag
=
" --amend "
let
commit
_flag
.
=
" --amend "
endif
silent
!
let
git_result
=
magit#utils#
system
(
g:magit_git_cmd
.
\
" commit "
.
amend_flag
.
" --file - "
,
commit_msg
)
let
commit_cmd
=
g:magit_git_cmd
.
" commit "
.
commit_flag
.
\
" --file - "
silent
!
let
git_result
=
magit#utils#
system
(
commit_cmd
,
commit_msg
)
let
b:magit_current_commit_mode
=
''
let
b:magit_current_commit_msg
=[]
endif
if
(
v
:
shell_error
!=
0
)
echoerr
"Git error: "
.
git_result
echohl ErrorMsg
echom
"Git error: "
.
git_result
echom
"Git cmd: "
.
commit_cmd
echohl None
endif
endfunction
...
...
@@ -1048,8 +1076,6 @@ function! magit#commit_command(mode)
" when we do commit, it is prefered ot commit the way we prepared it
" (.i.e normal or amend), whatever we commit with CC or CA.
call
<
SID
>
mg_git_commit
(
b:magit_current_commit_mode
)
let
b:magit_current_commit_mode
=
''
let
b:magit_current_commit_msg
=[]
else
let
b:magit_current_commit_mode
=
a:mode
let
b:magit_commit_newly_open
=
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment