Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 1.3.0: Added console support. Changed the way that files are …

…loaded.
  • Loading branch information...
commit 3b59ce3fef01a1d2f33ddfe372901d4820a948a1 1 parent 9c75c38
Peter Antoine authored committed
Showing with 34 additions and 40 deletions.
  1. +1 −1  README.md
  2. +3 −1 doc/gitlog.txt
  3. +30 −38 plugin/gitlog.vim
View
2  README.md
@@ -1,7 +1,7 @@
vimgitlog
=========
-Version: 1.2.0
+Version: 1.3.0
Git log and diff plugin for vim.
View
4 doc/gitlog.txt
@@ -11,7 +11,7 @@
Author: Peter Antoine
Date: December 14, 2012
-Version: 1.2.0
+Version: 1.3.0
HomePage: https://github.com/PAntoine/vimgitlog
@@ -140,6 +140,8 @@ This will install GITLOG on the <f7> key.
==============================================================================
5. History *gitlog-history*
+ 1.3.0: January 8, 2013
+ PA: Re-wrote the way that the files were read so it works in console mode.
1.2.0: December 14, 2012
PA: Added repository search capability.
View
68 plugin/gitlog.vim
@@ -26,7 +26,7 @@
" It is that simple.
"
" Author : peterantoine
-" version: 1.1.2
+" version: 1.3.0
" Date : 29/09/2012 14:42:03
" ---------------------------------------------------------------------------------
" Copyright (c) 2012 Peter Antoine
@@ -45,6 +45,9 @@
" fixed problem with un-escaped branchname causing
" git to not return list of changes.
" 1.2.0 PA 10.12.2012 Added searches.
+" 1.3.0 PA 08.01.2013 Re-wrote file opens and git commands to use the
+" system rather than the redir as this works on the
+" console version where redir does not.
" }}}
" PUBLIC FUNCTIONS
" FUNCTION: GITLOG_GetHistory(filename) "{{{
@@ -417,13 +420,11 @@ function! s:GITLOG_OpenLogWindow(file_name)
" now get the file history for the window
" rev-list does not support the --git-dir flag, so have to cd into the directory.
exec 'cd' fnameescape(s:repository_root)
- redir => gitdiff_history
- silent execute "!git --git-dir=" . s:repository_root . ".git rev-list " . shellescape(s:gitlog_current_branch,1) . " --oneline --graph -- " . a:file_name
- redir END
+ let run_command = 'git --git-dir=' . s:repository_root . ".git --no-pager rev-list " . shellescape(s:gitlog_current_branch,1) . " --oneline --graph -- " . a:file_name
+ let gitdiff_history = system(run_command)
cd -
- let git_array = split(substitute(gitdiff_history,'[\x00]',"","g"),"\x0d")
- call remove(git_array,0)
+ let git_array = split(gitdiff_history,'[\x00]')
call setline(1,[ 'branch: ' . s:gitlog_current_branch] + git_array)
" set the keys on the Log window
@@ -477,10 +478,10 @@ function! s:GITLOG_OpenBranchWindow()
setlocal modifiable
" now get the list of branches
- redir => gitbranch_history
- silent execute "!git --git-dir=" . s:repository_root . ".git branch -v"
- redir END
- let git_array = split(substitute(gitbranch_history,'[\x00]',"","g"),"\x0d")
+ let run_command = "git --git-dir=" . s:repository_root . ".git --no-pager branch -v"
+ let gitbranch_history = system(run_command)
+
+ let git_array = split(gitbranch_history,'[\x00]')
" set the current branch marker if it is not current real branch
if s:gitlog_branch_line != 0
@@ -490,7 +491,6 @@ function! s:GITLOG_OpenBranchWindow()
endif
endif
- call remove(git_array,0)
call setline(1,git_array)
" set the keys on the branch window
@@ -514,14 +514,12 @@ endfunction "}}}
" nothing
"
function! s:GITLOG_LoadRevisionFile(revision)
- redir => gitlog_file
- silent execute "!git --git-dir=" . s:repository_root . ".git --no-pager show " . a:revision
- redir END
+ let run_command = 'git --git-dir=" . s:repository_root . ".git --no-pager show " . a:revision
+ let gitlog_file = system(run_command)
" now write the captured text to the a new buffer - after removing
" the \x00's from the text and splitting into an array.
- let git_array = split(substitute(gitlog_file,'[\x00]',"","g"),"\x0d")
- call remove(git_array,0)
+ let git_array = split(gitlog_file,'[\x00]')
call setline(1,git_array)
setlocal buftype=nofile bufhidden=wipe nobuflisted nomodifiable noswapfile nowrap
@@ -567,14 +565,13 @@ function! s:GITLOG_OpenDiffWindow(commit,file_path,...)
diffthis
exe "silent rightbelow vnew " . buffname
- redir => gitlog_file
- silent execute "!git --git-dir=" . s:repository_root . ".git --no-pager show " . revision
- redir END
-
+ let run_command = "git --git-dir=" . s:repository_root . ".git --no-pager show " . revision
+ let gitlog_file = system(run_command)
+
+
" now write the captured text to the a new buffer - after removing
" the \x00's from the text and splitting into an array.
- let git_array = split(substitute(gitlog_file,'[\x00]',"","g"),"\x0d")
- call remove(git_array,0)
+ let git_array = split(gitlog_file,'[\x00]')
call setline(1,git_array)
setlocal buftype=nofile bufhidden=wipe nobuflisted nomodifiable noswapfile nowrap
diffthis
@@ -609,14 +606,12 @@ function! s:GITLOG_OpenCodeWindow(commit,file_path)
let file_type = &filetype
exe "silent rightbelow vnew " . buffname
- redir => gitlog_file
- silent execute "!git --git-dir=" . s:repository_root . ".git --no-pager show " . revision
- redir END
+ let run_command = "git --git-dir=" . s:repository_root . ".git --no-pager show " . revision
+ let gitlog_file = system(run_command)
" now write the captured text to the a new buffer - after removing
" the \x00's from the text and splitting into an array.
- let git_array = split(substitute(gitlog_file,'[\x00]',"","g"),"\x0d")
- call remove(git_array,0)
+ let git_array = split(gitlog_file,'[\x00]')
call setline(1,git_array)
setlocal buftype=nofile bufhidden=wipe nobuflisted nomodifiable noswapfile nowrap
exe "setlocal filetype=" . file_type
@@ -657,9 +652,8 @@ function! s:GITLOG_OpenSearchWindow()
let search_string = input("Search String: ","")
if !empty(search_string)
- redir => search_result
- silent execute "!git --git-dir=" . s:repository_root . ".git --no-pager grep -n -F " . search_string . s:selected_commits
- redir END
+ let run_command = "git --git-dir=" . s:repository_root . ".git --no-pager grep -n -F " . search_string . s:selected_commits
+ let search_result = system(run_command)
if v:shell_error
echohl WarningMsg
@@ -667,7 +661,8 @@ function! s:GITLOG_OpenSearchWindow()
echohl Normal
else
" ok, we found some stuff - open the window
- let search_result_list = split(substitute(search_result,'[\x00]',"","g"),"\x0d")
+ let search_result_list = split(search_result,'[\x00]')
+
if !empty(search_result_list)
if bufwinnr(bufnr("__gitsearch__")) != -1
" window already open - just go to it
@@ -688,13 +683,10 @@ function! s:GITLOG_OpenSearchWindow()
"need to change the window
setlocal modifiable
- let search_result_list = split(substitute(search_result,'[\x00]',"","g"),"\x0d")
- if !empty(search_result_list)
- " delete the contents then add the search results
- exe "% delete"
- call remove(search_result_list,0)
- call setline(1,search_result_list)
- endif
+ " delete the contents then add the search results
+ exe "% delete"
+ call remove(search_result_list,0)
+ call setline(1,search_result_list)
" Map the keys
call s:GITLOG_MapSearchBufferKeys()
Please sign in to comment.
Something went wrong with that request. Please try again.