git-control.vim 913 Bytes
Newer Older
Moritz Sokoll's avatar
Moritz Sokoll committed
1
2
" Name: git-control
" Author: Moritz Sokoll
Moritz Sokoll's avatar
Moritz Sokoll committed
3
" Description: a git version control integration for vim
Moritz Sokoll's avatar
Moritz Sokoll committed
4
5
6
7
8
9
10

if exists('g:git_control_loaded')
	finish
endif

function! Git_Commit()
	let commit_message = input('commit message: ')
Moritz Sokoll's avatar
Moritz Sokoll committed
11
	echo ''
Moritz Sokoll's avatar
ye    
Moritz Sokoll committed
12
	if len(commit_message) < 1
Moritz Sokoll's avatar
Moritz Sokoll committed
13
		echo 'message too short'
Moritz Sokoll's avatar
Moritz Sokoll committed
14
15
16
17
18
19
	else
		let stat = system("git commit -am '" . commit_message . "'")
		echo stat
	endif
endfunction

Moritz Sokoll's avatar
Moritz Sokoll committed
20
21
function! Git_Push()
	let stat = system('git push')
Moritz Sokoll's avatar
Moritz Sokoll committed
22
	echo stat
Moritz Sokoll's avatar
Moritz Sokoll committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
endfunction

function! Git_Checkout()
	let branch_name = input('branch: ')
	echo ''
	if len(branch_name) < 1
		echo 'branch name too short'
	elseif matchstr(branch_name, ' ') == ' '
		echo 'branch names cannot have spaces in them'
	else
		let stat = system('git checkout -b ' . branch_name)
		echo stat
	endif
endfunction

Moritz Sokoll's avatar
Moritz Sokoll committed
38
command! GitCommit call Git_Commit()
Moritz Sokoll's avatar
Moritz Sokoll committed
39
40
command! GitPush call Git_Push()
command! GitCheckout call Git_Checkout()
Moritz Sokoll's avatar
Moritz Sokoll committed
41
let g:git_control_loaded = 1