@@ -173,6 +173,34 @@ function! GitCatFile(file)
173
173
call <SID> OpenGitBuffer (git_output)
174
174
endfunction
175
175
176
+ " Show revision and author for each line.
177
+ function ! GitBlame ()
178
+ let git_output = s: SystemGit (' blame -- ' . expand (' %' ))
179
+ if ! strlen (git_output)
180
+ echo " No output from git command"
181
+ return
182
+ endif
183
+
184
+ setlocal noscrollbind
185
+
186
+ " :/
187
+ let git_command_edit_save = g: git_command_edit
188
+ let g: git_command_edit = ' leftabove vnew'
189
+ call <SID> OpenGitBuffer (git_output)
190
+ let g: git_command_edit = git_command_edit_save
191
+
192
+ setlocal modifiable
193
+ silent % s /\d\d\d\d\zs \+\d\+).*/ /
194
+ vertical resize 20
195
+ setlocal nomodifiable
196
+ setlocal nowrap scrollbind
197
+
198
+ wincmd p
199
+ setlocal nowrap scrollbind
200
+
201
+ syncbind
202
+ endfunction
203
+
176
204
function ! GitDoCommand (args )
177
205
let git_output = s: SystemGit (a: args )
178
206
let git_output = substitute (git_output, ' \n*$' , ' ' , ' ' )
@@ -265,6 +293,7 @@ command! -nargs=? GitAdd call GitAdd(<q-args>)
265
293
command ! -nargs =* GitLog call GitLog (<q-args> )
266
294
command ! -nargs =* GitCommit call GitCommit (<q-args> )
267
295
command ! -nargs =1 GitCatFile call GitCatFile (<q-args> )
296
+ command ! GitBlame call GitBlame ()
268
297
command ! -nargs =+ Git call GitDoCommand (<q-args> )
269
298
command ! GitVimDiffMerge call GitVimDiffMerge ()
270
299
command ! GitVimDiffMergeDone call GitVimDiffMergeDone ()
0 commit comments