~ubuntu-branches/ubuntu/maverick/vim/maverick

« back to all changes in this revision

Viewing changes to runtime/ftplugin/gitcommit.vim

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-06-26 13:42:18 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080626134218-703edeyb8k70qpbz
Tags: 1:7.1.314-3ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Enable detection of GNU screen as a mouse-capable terminal.
  - Add NoDisplay=true to gvim.desktop.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Build-depend on libxt-dev.
  - Enable Python interpreter on basic builds.
  - Create a .pot file for translations.
  - Disable autoindent, line-wrapping, and backup files by default.
* Fixes various vulnerabilities due to improper quoting of 'execute'
  arguments (LP: #240216).
* Drop fixes for upgrade problems from Ubuntu 6.06 LTS; direct upgrades
  from 6.06 to 8.10 will not be supported.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
" Vim filetype plugin
2
2
" Language:     git config file
3
3
" Maintainer:   Tim Pope <vimNOSPAM@tpope.info>
4
 
" Last Change:  2007 Dec 16
 
4
" Last Change:  2008 Jun 04
5
5
 
6
6
" Only do this when not done yet for this buffer
7
7
if (exists("b:did_ftplugin"))
8
8
  finish
9
9
endif
 
10
 
 
11
runtime! ftplugin/git.vim
10
12
let b:did_ftplugin = 1
11
13
 
12
 
" allow gf to work even if in a subdirectory
13
 
let b:git_dir = expand("%:p:h")
14
 
let &l:path = fnamemodify(b:git_dir,':h').",".&l:path
15
 
let b:undo_ftplugin = "setl path<"
16
 
 
17
14
if &textwidth == 0
18
15
  " make sure that log messages play nice with git-log on standard terminals
19
16
  setlocal textwidth=72
20
 
  let b:undo_ftplugin = b:undo_ftplugin . " tw<"
 
17
  if !exists("b:undo_ftplugin")
 
18
      let b:undo_ftplugin = ""
 
19
  endif
 
20
  let b:undo_ftplugin = b:undo_ftplugin . "|setl tw<"
21
21
endif
22
22
 
23
 
if exists("g:no_gitcommit_commands")
 
23
if exists("g:no_gitcommit_commands") || v:version < 700
24
24
  finish
25
25
endif
26
26
 
 
27
if !exists("b:git_dir")
 
28
    let b:git_dir = expand("%:p:h")
 
29
endif
 
30
 
27
31
" Automatically diffing can be done with:
28
32
"   autocmd FileType gitcommit DiffGitCached | wincmd p
29
33
command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)
45
49
function! s:gitdiffcached(bang,gitdir,...)
46
50
    let tree = fnamemodify(a:gitdir,':h')
47
51
    let name = tempname()
48
 
    let prefix = ""
 
52
    let git = "git"
49
53
    if strpart(getcwd(),0,strlen(tree)) != tree
50
 
        if has("win32")
51
 
            let oldgit = $GIT_DIR
52
 
            let $GIT_DIR = a:gitdir
53
 
        else
54
 
            " Can't unset an env var, so use shell syntax instead
55
 
            let prefix = 'GIT_DIR='.shellescape(a:gitdir).' '
56
 
        endif
 
54
        let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"')
57
55
    endif
58
56
    if a:0
59
 
        let extra = join(map(copy(a:000),has("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'"))
 
57
        let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'"))
60
58
    else
61
59
        let extra = "-p --stat=".&columns
62
60
    endif
63
 
    call system(prefix."git diff --cached --no-color ".extra." > ".name)
64
 
    if exists("l:oldgit")
65
 
        let $GIT_DIR = oldgit
66
 
    endif
67
 
    exe "pedit ".name
 
61
    call system(git." diff --cached --no-color ".extra." > ".(exists("*shellescape") ? shellescape(name) : name))
 
62
    exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name)
68
63
    wincmd P
69
64
    let b:git_dir = a:gitdir
70
65
    command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)
71
66
    nnoremap <silent> q :q<CR>
72
 
    setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=diff
73
 
    setlocal keywordprg=git\ show includeexpr=substitute(v:fname,'^[ab]/','','')
74
 
    if strpart(&l:path,0,strlen(tree)) != tree
75
 
        let &l:path = tree.','.&l:path
76
 
    endif
 
67
    setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git
77
68
endfunction