File: git-branch

package info (click to toggle)
yash 2.43-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,184 kB
  • ctags: 3,159
  • sloc: ansic: 31,766; makefile: 812; sh: 407; sed: 16
file content (93 lines) | stat: -rw-r--r-- 2,449 bytes parent folder | download | duplicates (5)
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
# (C) 2011-2014 magicant

# Completion script for the "git-branch" command.
# Supports Git 1.9.0.

function completion/git-branch {
	WORDS=(git branch "${WORDS[2,-1]}")
	command -f completion//reexecute
}

function completion/git::branch:arg {

	OPTIONS=( #>#
	"--abbrev:; specify the number of commit ID digits to print"
	"a --all; print local and remote-tracking branches"
	"--color::; show symbols in color"
	"--column::; columnize output"
	"--contains; show branches that contain the specified commit only"
	"l --create-reflog; enable reflog for the new branch"
	"D; delete a branch that has not been merged"
	"d --delete; delete a branch"
	"--edit; edit the branch explanation with an editor"
	"f --force; overwrite an existing branch"
	"--list; list branches matching the operand pattern"
	"M; rename a branch, overwriting an existing branch"
	"--merged; show branches that are contained in the specified commit only"
	"m --move; rename a branch"
	"--no-abbrev; print full commit IDs"
	"--no-color; like --color=never"
	"--no-column; print branches line by line"
	"--no-merged; show branches that aren't contained in the specified commit only"
	"--no-track; create a non-tracking branch"
	"q --quiet; print error messages only"
	"r --remotes; print or delete remote-tracking branches"
	"--set-upstream; like --track, but don't move HEAD"
	"u: --set-upstream-to:; set the upstream to the specified one"
	"t --track; create a remote-tracking branch"
	"--unset-upstream; remove the upstream"
	"v --verbose; print commit ID and summary for each branch"
	) #<#

	command -f completion//parseoptions -n
	case $ARGOPT in
		(-)
			command -f completion//completeoptions
			;;
		(--abbrev)
			;;
		(--color|--column)
			command -f completion/git::$ARGOPT:arg
			;;
		(u|--set-upstream-to)
			command -f completion/git::completeref --remotes
			;;
		('')
			typeset i=2 all=false delete=false
			while [ $i -le ${WORDS[#]} ]; do
				case ${WORDS[i]} in
				(--)
					i=$((i+1))
					break
					;;
				(--merged|--no-merged|--contains)
					all=true
					break
					;;
				(--*)
					i=$((i+1))
					;;
				(-*[Dd]*)
					delete=true
					break
					;;
				(-?*)
					i=$((i+1))
					;;
				(*)
					break
					;;
				esac
			done
			if ! $all && $delete || [ $i -gt ${WORDS[#]} ]; then
				command -f completion/git::completeref --branches
			else
				command -f completion/git::completeref
			fi
			;;
	esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 noet: