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
0e7ddb6c
Commit
0e7ddb6c
authored
9 years ago
by
Jerome Reybert
Browse files
Options
Downloads
Patches
Plain Diff
autoload/magit/state.vim: manage submodules (fix #12)
parent
868dab5b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
autoload/magit/state.vim
+11
-4
11 additions, 4 deletions
autoload/magit/state.vim
autoload/magit/utils.vim
+14
-0
14 additions, 0 deletions
autoload/magit/utils.vim
common/magit_common.vim
+1
-0
1 addition, 0 deletions
common/magit_common.vim
plugin/magit.vim
+5
-1
5 additions, 1 deletion
plugin/magit.vim
with
31 additions
and
5 deletions
autoload/magit/state.vim
+
11
−
4
View file @
0e7ddb6c
...
@@ -22,7 +22,8 @@ function! magit#state#must_be_added() dict
...
@@ -22,7 +22,8 @@ function! magit#state#must_be_added() dict
return
(
self
.
empty
==
1
||
return
(
self
.
empty
==
1
||
\
self
.
symlink
!=
''
||
\
self
.
symlink
!=
''
||
\
self
.
dir
!=
0
||
\
self
.
dir
!=
0
||
\
self
.
binary
==
1
)
\
self
.
binary
==
1
||
\
self
.
submodule
==
1
)
endfunction
endfunction
" magit#state#file_get_hunks: function accessor for hunks objects
" magit#state#file_get_hunks: function accessor for hunks objects
...
@@ -66,6 +67,7 @@ let s:file_template = {
...
@@ -66,6 +67,7 @@ let s:file_template = {
\
'empty'
:
0
,
\
'empty'
:
0
,
\
'dir'
:
0
,
\
'dir'
:
0
,
\
'binary'
:
0
,
\
'binary'
:
0
,
\
'submodule'
:
0
,
\
'symlink'
:
''
,
\
'symlink'
:
''
,
\
'diff'
:
s:diff_template
,
\
'diff'
:
s:diff_template
,
\
'is_dir'
:
function
(
"magit#state#is_file_dir"
),
\
'is_dir'
:
function
(
"magit#state#is_file_dir"
),
...
@@ -125,8 +127,14 @@ function! magit#state#add_file(mode, status, filename, depth) dict
...
@@ -125,8 +127,14 @@ function! magit#state#add_file(mode, status, filename, depth) dict
let
file
.
depth
=
a:depth
let
file
.
depth
=
a:depth
if
(
a:status
==
'?'
&&
getftype
(
a:filename
)
==
'link'
)
if
(
a:status
==
'?'
&&
getftype
(
a:filename
)
==
'link'
)
let
file
.
symlink
=
resolve
(
a:filename
)
let
file
.
symlink
=
resolve
(
a:filename
)
call
add
(
file
.
diff
.
header
,
'no header'
)
let
file
.
diff
.
hunks
[
0
].
header
=
'New symbolic link file'
let
file
.
diff
.
hunks
[
0
].
header
=
'New symbolic link file'
elseif
(
magit#utils#is_submodule
(
a:filename
))
let
file
.
submodule
=
1
let
file
.
diff
.
hunks
[
0
].
header
=
''
let
file
.
diff
.
hunks
[
0
].
lines
=
diff_list
if
(
file
.
is_visible
()
)
let
self
.
nb_diff_lines
+=
len
(
diff_list
)
endif
elseif
(
a:status
==
'?'
&&
isdirectory
(
a:filename
)
==
1
)
elseif
(
a:status
==
'?'
&&
isdirectory
(
a:filename
)
==
1
)
let
file
.
dir
=
1
let
file
.
dir
=
1
for
subfile
in
split
(
globpath
(
a:filename
,
'\(.[^.]*\|*\)'
),
'\n'
)
for
subfile
in
split
(
globpath
(
a:filename
,
'\(.[^.]*\|*\)'
),
'\n'
)
...
@@ -134,11 +142,9 @@ function! magit#state#add_file(mode, status, filename, depth) dict
...
@@ -134,11 +142,9 @@ function! magit#state#add_file(mode, status, filename, depth) dict
endfor
endfor
elseif
(
a:status
==
'?'
&&
getfsize
(
a:filename
)
==
0
)
elseif
(
a:status
==
'?'
&&
getfsize
(
a:filename
)
==
0
)
let
file
.
empty
=
1
let
file
.
empty
=
1
call
add
(
file
.
diff
.
header
,
'no header'
)
let
file
.
diff
.
hunks
[
0
].
header
=
'New empty file'
let
file
.
diff
.
hunks
[
0
].
header
=
'New empty file'
elseif
(
magit#utils#is_binary
(
magit#utils#add_quotes
(
a:filename
)))
elseif
(
magit#utils#is_binary
(
magit#utils#add_quotes
(
a:filename
)))
let
file
.
binary
=
1
let
file
.
binary
=
1
call
add
(
file
.
diff
.
header
,
'no header'
)
let
file
.
diff
.
hunks
[
0
].
header
=
'Binary file'
let
file
.
diff
.
hunks
[
0
].
header
=
'Binary file'
else
else
let
line
=
0
let
line
=
0
...
@@ -184,6 +190,7 @@ function! magit#state#update() dict
...
@@ -184,6 +190,7 @@ function! magit#state#update() dict
let
dir
=
getcwd
()
let
dir
=
getcwd
()
try
try
call
magit#utils#
lcd
(
magit#utils#top_dir
())
call
magit#utils#
lcd
(
magit#utils#top_dir
())
call
magit#utils#refresh_submodule_list
()
for
[
mode
,
diff_dict_mode
]
in
items
(
self
.
dict
)
for
[
mode
,
diff_dict_mode
]
in
items
(
self
.
dict
)
let
status_list
=
magit#git#get_status
()
let
status_list
=
magit#git#get_status
()
for
file_status
in
status_list
for
file_status
in
status_list
...
...
This diff is collapsed.
Click to expand it.
autoload/magit/utils.vim
+
14
−
0
View file @
0e7ddb6c
...
@@ -40,6 +40,20 @@ function! magit#utils#is_binary(filename)
...
@@ -40,6 +40,20 @@ function! magit#utils#is_binary(filename)
\
a:filename
.
".*charset=binary"
)
!=
-1
)
\
a:filename
.
".*charset=binary"
)
!=
-1
)
endfunction
endfunction
let
s:submodule_list
=
[]
" magit#utils#refresh_submodule_list: this function refresh the List s:submodule_list
" magit#utils#is_submodule() is using s:submodule_list
function
!
magit#utils#refresh_submodule_list
()
let
s:submodule_list
=
map
(
split
(
system
(
"git submodule status"
),
"\n"
),
'split(v:val)[1]'
)
endfunction
" magit#utils#is_submodule search if dirname is in s:submodule_list
" param[in] dirname: must end with /
" INFO: must be called from top work tree
function
!
magit#utils#is_submodule
(
dirname
)
return
(
index
(
s:submodule_list
,
a:dirname
)
!=
-1
)
endfunction
" s:magit_cd_cmd: plugin variable to choose lcd/cd command, 'lcd' if exists,
" s:magit_cd_cmd: plugin variable to choose lcd/cd command, 'lcd' if exists,
" 'cd' otherwise
" 'cd' otherwise
let
s:magit_cd_cmd
=
exists
(
'*haslocaldir'
)
&&
haslocaldir
()
?
'lcd '
:
'cd '
let
s:magit_cd_cmd
=
exists
(
'*haslocaldir'
)
&&
haslocaldir
()
?
'lcd '
:
'cd '
...
...
This diff is collapsed.
Click to expand it.
common/magit_common.vim
+
1
−
0
View file @
0e7ddb6c
...
@@ -22,6 +22,7 @@ let g:magit_git_status_code = {
...
@@ -22,6 +22,7 @@ let g:magit_git_status_code = {
\
'E'
:
'empty'
,
\
'E'
:
'empty'
,
\
'L'
:
'symlink'
,
\
'L'
:
'symlink'
,
\
'N'
:
'new dir'
,
\
'N'
:
'new dir'
,
\
'S'
:
'submodule'
,
\
}
\
}
" Regular expressions used to select blocks
" Regular expressions used to select blocks
...
...
This diff is collapsed.
Click to expand it.
plugin/magit.vim
+
5
−
1
View file @
0e7ddb6c
...
@@ -156,6 +156,8 @@ function! s:mg_display_files(mode, curdir, depth)
...
@@ -156,6 +156,8 @@ function! s:mg_display_files(mode, curdir, depth)
put
=
g:magit_git_status_code
.
E
.
': '
.
filename
put
=
g:magit_git_status_code
.
E
.
': '
.
filename
elseif
(
file
.
symlink
!=
''
)
elseif
(
file
.
symlink
!=
''
)
put
=
g:magit_git_status_code
.
L
.
': '
.
filename
.
' -> '
.
file
.
symlink
put
=
g:magit_git_status_code
.
L
.
': '
.
filename
.
' -> '
.
file
.
symlink
elseif
(
file
.
submodule
==
1
)
put
=
g:magit_git_status_code
.
S
.
': '
.
filename
elseif
(
file
.
dir
!=
0
)
elseif
(
file
.
dir
!=
0
)
put
=
g:magit_git_status_code
.
N
.
': '
.
filename
put
=
g:magit_git_status_code
.
N
.
': '
.
filename
if
(
file
.
visible
==
1
)
if
(
file
.
visible
==
1
)
...
@@ -174,7 +176,9 @@ function! s:mg_display_files(mode, curdir, depth)
...
@@ -174,7 +176,9 @@ function! s:mg_display_files(mode, curdir, depth)
endif
endif
let
hunks
=
file
.
get_hunks
()
let
hunks
=
file
.
get_hunks
()
for
hunk
in
hunks
for
hunk
in
hunks
if
(
hunk
.
header
!=
''
)
silent
put
=
hunk
.
header
silent
put
=
hunk
.
header
endif
silent
put
=
hunk
.
lines
silent
put
=
hunk
.
lines
endfor
endfor
put
=
''
put
=
''
...
...
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