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
d77693b6
Commit
d77693b6
authored
Oct 30, 2015
by
Jerome Reybert
Browse files
Options
Downloads
Patches
Plain Diff
autoload/magit/utils.vim: add git_add and git_reset helper functions
parent
c10c9cad
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
autoload/magit/utils.vim
+25
-0
25 additions, 0 deletions
autoload/magit/utils.vim
plugin/magit.vim
+2
-4
2 additions, 4 deletions
plugin/magit.vim
with
27 additions
and
4 deletions
autoload/magit/utils.vim
+
25
−
0
View file @
d77693b6
...
@@ -33,6 +33,31 @@ function! magit#utils#git_dir()
...
@@ -33,6 +33,31 @@ function! magit#utils#git_dir()
return
s:magit_git_dir
return
s:magit_git_dir
endfunction
endfunction
" magit#utils#git_add: helper function to add a whole file
" nota: when git fail (due to misformated patch for example), an error
" message is raised.
" param[in] filemane: it must be quoted if it contains spaces
function
!
magit#utils#git_add
(
filename
)
let
git_cmd
=
"git add -- "
.
a:filename
silent
let
git_result
=
magit#utils#
system
(
git_cmd
)
if
(
v
:
shell_error
!=
0
)
echoerr
"Git error: "
.
git_result
echoerr
"Git cmd: "
.
git_cmd
endif
endfunction
" magit#utils#git_reset: helper function to add a whole file
" nota: when git fail (due to misformated patch for example), an error
" message is raised.
" param[in] filemane: it must be quoted if it contains spaces
function
!
magit#utils#git_reset
(
filename
)
let
git_cmd
=
"git reset -- "
.
a:filename
silent
let
git_result
=
magit#utils#
system
(
git_cmd
)
if
(
v
:
shell_error
!=
0
)
echoerr
"Git error: "
.
git_result
echoerr
"Git cmd: "
.
git_cmd
endif
endfunction
" magit#utils#git_apply: helper function to stage a selection
" magit#utils#git_apply: helper function to stage a selection
" nota: when git fail (due to misformated patch for example), an error
" nota: when git fail (due to misformated patch for example), an error
...
...
This diff is collapsed.
Click to expand it.
plugin/magit.vim
+
2
−
4
View file @
d77693b6
...
@@ -677,15 +677,13 @@ function! magit#stage_block(selection, discard) abort
...
@@ -677,15 +677,13 @@ function! magit#stage_block(selection, discard) abort
if
(
a:discard
==
0
)
if
(
a:discard
==
0
)
if
(
section
==
'unstaged'
)
if
(
section
==
'unstaged'
)
if
(
file
.
must_be_added
()
)
if
(
file
.
must_be_added
()
)
call
magit#utils#
system
(
'git add '
.
call
magit#utils#git_add
(
magit#utils#add_quotes
(
filename
))
\
magit#utils#add_quotes
(
filename
))
else
else
call
magit#utils#git_apply
(
header
,
a:selection
)
call
magit#utils#git_apply
(
header
,
a:selection
)
endif
endif
elseif
(
section
==
'staged'
)
elseif
(
section
==
'staged'
)
if
(
file
.
must_be_added
()
)
if
(
file
.
must_be_added
()
)
call
magit#utils#
system
(
'git reset '
.
call
magit#utils#git_reset
(
magit#utils#add_quotes
(
filename
))
\
magit#utils#add_quotes
(
filename
))
else
else
call
magit#utils#git_unapply
(
header
,
a:selection
,
'staged'
)
call
magit#utils#git_unapply
(
header
,
a:selection
,
'staged'
)
endif
endif
...
...
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