forked from jreybert/vimagit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiffs
289 lines (267 loc) · 11.1 KB
/
diffs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
diff --git a/Changelog b/Changelog
index e7a9a2a..d4a7751 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,42 @@
+Release 1.8.0
+=============
+
+New features
+------------
+
+* feat: add update mode to speed up update
+
+
+Updates
+-------
+
+* Rework and simplify magit#utils#search_buffer_in_windows usage
+
+Bug fixes
+---------
+
+* Fix jump_to exception
+* Fix jump_to function when jumping to a dirty existing buffer
+* Force git commit cleanup
+* Update mg_get_commit_section function
+* Merge pull request #195 from jreybert/next
+* Fix very slow update when large submodule
+* check_repo() can't use 'count' for a variable name.
+* Make top level git path work with Cygwin/MSYS2
+* Use cygpath if present to create top level dir for Cygwin/MSYS2 compatibility
+* Use --no-prefix to generate diff
+* perf: get git status only once per refresh
+* Always specify diff prefix to avoid diff.noprefix errors
+* Set scrolloff in magit buffer
+
+Contributors
+------------
+
+Thanks to users who have contributed to this release:
+* @arafel
+* @wwade
+* @pnetherwood
+
Release 1.7.3
=============
diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim
index 5bc67da..69dc7a9 100644
--- a/autoload/magit/git.vim
+++ b/autoload/magit/git.vim
@@ -17,14 +17,19 @@ endfunction
" magit#git#get_status: this function returns the git status output formated
" into a List of Dict as
" [ {staged', 'unstaged', 'filename'}, ... ]
-function! magit#git#get_status()
+function! magit#git#get_status(update_mode)
let file_list = []
" systemlist v7.4.248 problem again
" we can't use git status -z here, because system doesn't make the
" difference between NUL and NL. -status z terminate entries with NUL,
" instead of NF
- let status_list=magit#sys#systemlist(g:magit_git_cmd . " status --porcelain")
+ if a:update_mode == 'fast'
+ let ignore_flag = 'dirty'
+ else
+ let ignore_flag = 'none'
+ endif
+ let status_list=magit#sys#systemlist(g:magit_git_cmd . " status --porcelain --ignore-submodules=" . ignore_flag)
for file_status_line in status_list
let line_match = matchlist(file_status_line, '\(.\)\(.\) \%(.\{-\} -> \)\?"\?\(.\{-\}\)"\?$')
let filename = line_match[3]
@@ -153,10 +158,8 @@ endfunction
" untracked content
" param[in] submodule: submodule path
" param[in] check_level: can be modified or untracked
-function! magit#git#sub_check(submodule, check_level)
- let ignore_flag = ( a:check_level == 'modified' ) ?
- \ '--ignore-submodules=untracked' : ''
- let git_cmd=g:magit_git_cmd . " status --porcelain " . ignore_flag . " " . a:submodule
+function! magit#git#sub_check(submodule, ignore_flag)
+ let git_cmd=g:magit_git_cmd . " status --porcelain --ignore-submodules=" . a:ignore_flag . " " . a:submodule
return ( !empty(magit#sys#systemlist(git_cmd)) )
endfunction
@@ -172,10 +175,10 @@ function! magit#git#git_sub_summary(filename, mode)
silent let diff_list=magit#sys#systemlist(git_cmd)
if ( empty(diff_list) )
if ( a:mode == 'unstaged' )
- if ( magit#git#sub_check(a:filename, 'modified') )
+ if ( magit#git#sub_check(a:filename, 'untracked') )
return "modified content"
endif
- if ( magit#git#sub_check(a:filename, 'untracked') )
+ if ( magit#git#sub_check(a:filename, 'none') )
return "untracked content"
endif
endif
diff --git a/autoload/magit/state.vim b/autoload/magit/state.vim
index 5148853..379308c 100644
--- a/autoload/magit/state.vim
+++ b/autoload/magit/state.vim
@@ -277,7 +277,7 @@ function! magit#state#update() dict
try
call magit#utils#chdir(magit#git#top_dir())
call magit#utils#refresh_submodule_list()
- let status_list = magit#git#get_status()
+ let status_list = magit#git#get_status(b:magit_update_mode)
for [mode, diff_dict_mode] in items(self.dict)
for file_status in status_list
let status=file_status[mode]
diff --git a/common/magit_common.vim b/common/magit_common.vim
index f1f8123..72b7f26 100644
--- a/common/magit_common.vim
+++ b/common/magit_common.vim
@@ -16,6 +16,7 @@ let g:magit_section_info = {
\ 'cur_upstream': 'Upstream:',
\ 'cur_push': 'Push:',
\ 'commit_mode': 'Commit mode:',
+ \ 'update_mode': 'Update mode:',
\ }
let g:magit_git_status_code = {
diff --git a/doc/vimagit.txt b/doc/vimagit.txt
index e0ef71e..aeaa4a0 100644
--- a/doc/vimagit.txt
+++ b/doc/vimagit.txt
@@ -366,6 +366,24 @@ section only.
------------------------------------------------------------------------------
+UPDATE MODE *vimagit-update-mode*
+
+Update can be slow, especially when the repository has a lot of (recursive)
+submodules. To speed up update, submodules status can be lighter.
+
+By setting update mode to normal, git status performs the default behavior.
+By setting update mode to fast, git status will use the option
+`--ignore-submodules=dirty`. This option will only search for commit changes
+in the submodules. All modified and untracked changes will be ignored.
+
+It is possible to control this option by two ways:
+- globally, by setting the vim option `g:magit_update_mode`
+- at repository level, by setting the git option:
+ `git config vimagit.update-mode fast`
+- for the record, it is also possible to set the option globally with git:
+ `git config --global vimagit.update-mode fast`
+
+------------------------------------------------------------------------------
AUTOCMD *vimagit-autocmd*
@@ -517,6 +535,11 @@ empty).
Default value is 0.
let g:magit_auto_close=[01]
+ *vimagit-g:magit_update_mode*
+See |vimagit-update-mode|.
+Can be set to 'normal' and 'fast'.
+Default value is 'normal'.
+
===============================================================================
6. FAQ *vimagit-FAQ*
diff --git a/plugin/magit.vim b/plugin/magit.vim
index befe97f..c1a897c 100644
--- a/plugin/magit.vim
+++ b/plugin/magit.vim
@@ -5,7 +5,7 @@ if exists('g:loaded_magit') || !executable('git') || &cp
endif
let g:loaded_magit = 1
-let g:vimagit_version = [1, 7, 3]
+let g:vimagit_version = [1, 8, 0]
" Initialisation {{{
@@ -32,6 +32,10 @@ let g:magit_default_sections = get(g:, 'magit_default_sections',
let g:magit_discard_untracked_do_delete = get(g:, 'magit_discard_untracked_do_delete', 0)
let g:magit_refresh_gutter = get(g:, 'magit_refresh_gutter' , 1)
+
+let g:magit_update_mode = get(g:, 'magit_update_mode', 'normal')
+let g:magit_update_modes = ['normal', 'fast']
+
" Should deprecate the following
let g:magit_refresh_gitgutter = get(g:, 'magit_refresh_gitgutter', 0)
@@ -97,7 +101,12 @@ function! s:mg_get_info()
let upstream_msg=s:mg_cut_str(magit#git#get_commit_subject(upstream_br), limit)
let push_msg=s:mg_cut_str(magit#git#get_commit_subject(push_br), limit)
- let head_line=magit#utils#strip(printf("%-*s %-*s %s",
+ let update_msg = ""
+ if b:magit_last_update_time > 1.0 && b:magit_update_mode_undefined == 1
+ \ && b:magit_update_mode != 'fast'
+ let update_msg = "update is slow, consider fast update `:help vimagit-update-mode`"
+ endif
+ let head_line=magit#utils#strip(printf("%-*s %-*s %s",
\ align_w, g:magit_section_info.cur_head,
\ max_br_w, head_br, head_msg))
let upstream_line=magit#utils#strip(printf("%-*s %-*s %s",
@@ -107,6 +116,10 @@ function! s:mg_get_info()
\ align_w, g:magit_section_info.cur_push,
\ max_br_w, push_br, push_msg))
+ let update_line=magit#utils#strip(printf("%-*s %-*s %s",
+ \ align_w, g:magit_section_info.update_mode,
+ \ max_br_w, b:magit_update_mode, update_msg))
+
silent put =g:magit_sections.info
silent put =magit#utils#underline(g:magit_sections.info)
silent put =''
@@ -114,6 +127,7 @@ function! s:mg_get_info()
silent put =head_line
silent put =upstream_line
silent put =push_line
+ silent put =update_line
if ( b:magit_current_commit_mode != '' )
let commit_mode_line=printf("%-*s %s",
@@ -618,7 +632,15 @@ function! magit#update_buffer(...)
let prev_filename = (pos > 0) ? filenames[pos-1] : ''
endif
+ if has('reltime')
+ let start_time = reltime()
+ endif
call b:state.update()
+ if has('reltime')
+ let b:magit_last_update_time = reltimefloat(start_time)
+ else
+ let b:magit_last_update_time = 0
+ endif
if ( g:magit_auto_close == 1 &&
\ b:magit_just_commited == 1 &&
@@ -871,6 +893,30 @@ function! magit#show_magit(display, ...)
return
endif
+ if index(g:magit_update_modes, g:magit_update_mode) == -1
+ echohl WarningMsg
+ echom "g:magit_update_mode='" . g:magit_update_mode . "' must be one of the following: " . join(g:magit_update_modes, ',')
+ echom "Reset to normal"
+ echohl None
+ let g:magit_update_mode = 'normal'
+ endif
+
+ let update_mode = magit#git#get_config('vimagit.update-mode', 'undefined')
+ if update_mode == 'undefined'
+ let b:magit_update_mode_undefined = 1
+ let b:magit_update_mode = g:magit_update_mode
+ else
+ let b:magit_update_mode_undefined = 0
+ if index(g:magit_update_modes, update_mode) == -1
+ echohl WarningMsg
+ echom "vimagit.update-mode='" . update_mode . "' (gitconfig) must be one of the following: " . join(g:magit_update_modes, ',')
+ echom "Reset to g:magit_update_mode"
+ echohl None
+ let update_mode = g:magit_update_mode
+ endif
+ let b:magit_update_mode = update_mode
+ endif
+
let b:state = deepcopy(g:magit#state#state)
call magit#utils#setbufnr(bufnr(buffer_name))
call magit#sign#init()
diff --git a/syntax/magit.vim b/syntax/magit.vim
index 6225e87..4ca39ca 100644
--- a/syntax/magit.vim
+++ b/syntax/magit.vim
@@ -37,6 +37,7 @@ execute 'syn match gitInfoRepo "\%(' . g:magit_section_info.cur_repo . '\)\@<=
execute 'syn match gitInfoHead "\%(' . g:magit_section_info.cur_head . '\s*\)\@<=\S\+" oneline'
execute 'syn match gitInfoUpstream "\%(' . g:magit_section_info.cur_upstream . '\s*\)\@<=\S\+" oneline'
execute 'syn match gitInfoPush "\%(' . g:magit_section_info.cur_push . '\s*\)\@<=\S\+" oneline'
+execute 'syn match gitUpdateMode "\%(' . g:magit_section_info.update_mode . '\s*\)\@<=\S\+" oneline'
execute 'syn match gitCommitMode "\%(' . g:magit_section_info.commit_mode . '\)\@<=.*$" oneline'
"execute 'syn match gitInfoCommit "\%(' . g:magit_section_info.cur_commit . '\)\@<=.*$" contains=infoSha1 oneline'
"syntax match infoSha1 containedin=gitInfoCommit "\x\{7,}"
@@ -45,6 +46,7 @@ highlight default link gitInfoRepo Directory
highlight default link gitInfoHead Identifier
highlight default link gitInfoUpstream Identifier
highlight default link gitInfoPush Identifier
+highlight default link gitUpdateMode Identifier
highlight default link gitCommitMode Special
highlight default link infoSha1 Identifier