File: _git-cola

package info (click to toggle)
git-cola 4.13.0-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 6,480 kB
  • sloc: python: 36,938; sh: 304; makefile: 223; xml: 100; tcl: 62
file content (169 lines) | stat: -rw-r--r-- 4,013 bytes parent folder | download | duplicates (2)
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
#compdef git-cola
#description zsh completion for git-cola
#
# The recommended way to install this script is to make a copy of it as a
# file named '_git-cola' inside any directory in your fpath.
#
# For example, create a directory '~/.config/zsh/completion',
# copy this file to '~/.config/zsh/completion/_git-cola',
# and then add the following to your ~/.zshrc file:
#
#  fpath=(~/.config/zsh/completion $fpath)

__git-cola_common_options () {
	# these can't be prefixed
	_arguments '--help[Show help]' \
		'--icon-theme=-[specify an icon theme name or directory]:theme:(dark light default)' \
		'--theme=-[specify a GUI theme name]:theme:(dark light default)' \
		'--prompt[prompt for a repository]' \
		'--repo=-[open the specified git repository]:repository:_files -/' \
		'--version[print version number]'
}

_git-cola_refs () {
	typeset -a refs
	local ref

	if git rev-parse HEAD >/dev/null 2>&1
	then
		for ref in $(git for-each-ref --format='%(refname:short)')
		do
			refs+=(${ref})
		done

		(( $#refs )) && _describe -t refs 'refs' refs
	fi

}

_git-cola-am () {
	__git-cola_common_options
	_arguments \
		'*:patches:_files -g "*.patch"'
}

_git-cola-archive () {
	__git-cola_common_options
	_arguments \
		':ref:_git-cola_refs'
}

_git-cola-cola () {
	__git-cola_common_options
	_arguments \
		'--status-filter=-[status path filter]:path:_files'
}

_git-cola-dag () {
	__git-cola_common_options
	_arguments \
		'--all[show all branches]' \
		'*:refs:_git-cola_refs'
}

_git-cola-diff () {
	__git-cola_common_options
	_arguments \
		'*:refs:_git-cola_refs'
}

_git-cola-find () {
	__git-cola_common_options
	_arguments \
		':path:_files'
}

_git-cola-grep () {
	__git-cola_common_options
	_arguments \
		'*:path:_files'
}

_git-cola-merge () {
	__git-cola_common_options
	_arguments \
		':ref:_git-cola_refs'
}

_git-cola-rebase () {
	__git-cola_common_options
	_arguments \
		'--autosquash[move commits that begin with squash!/fixup!]' \
		'--autostash[automatically stash/stash pop before and after]' \
		'--fork-point[use "merge-base --fork-point" to refine upstream]' \
		'--onto=-[rebase onto given branch instead of upstream]:ref:_git-cola_refs' \
		'--preserve-merges[try to recreate merges instead of ignoring them]' \
		'--root[rebase all reachable commits up to the root(s)]' \
		'--strategy=-[use the given merge strategy]:strategy:(recursive resolve octopus ort ours subtree)' \
		'--verify[allow pre-rebase hook to run]' \
		'--continue[continue]' \
		'--abort[abort and check out the original branch]' \
		'--skip[skip current patch and continue]' \
		'--edit-todo[edit the todo list]' \
		':ref:_git-cola_refs' \
		':ref:_git-cola_refs'
}

_git-cola-tag () {
	__git-cola_common_options
	_arguments \
		'--sign[annotated and GPG-signed tag]' \
		':tag name:' \
		':ref:_git-cola_refs'
}


_git-cola () {
	local curcontext="$curcontext" state line
	typeset -A opt_args
	_arguments -C \
		':command:->command' \
		'*::options:->options' \

	case $state in
	(command)
		#breaks if defined outside the func
		local -a subcommands
		subcommands=(
			'about:about git-cola'
			'am:apply patches using "git am"'
			'archive:save an archive'
			'branch:create a branch'
			'browse:browse repository'
			'clone:clone repository'
			'cola:start git-cola'
			'config:edit configuration'
			'dag:visualize branch history'
			'diff:view diffs'
			'fetch:fetch remotes'
			'find:find files'
			'grep:grep source'
			'merge:merge branches'
			'pull:pull remote branches'
			'push:push remote branches'
			'rebase:interactive rebase'
			'recent:edit recent files'
			'remote:edit remotes'
			'search:search commits'
			'stash:stash and unstash changes'
			'tag:create tags'
			'version:print the version'
			'--help-commands:show available sub-commands'
		)

		_describe -t commands git-cola subcommands
	;;
	(options)
		local funcname
		funcname=_git-cola-$line[1]
		if type $funcname | grep -q 'shell function'
		then
			$funcname
		else
			__git-cola_common_options
		fi
	;;
	esac
}

_git-cola "$@"