forked from eacousineau/util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-sube
124 lines (121 loc) · 2.61 KB
/
git-sube
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
#!bash
# Submodule extensions for git - E. A. Cousineau ([email protected])
# Bash completion functions - R. W. Sinnet ([email protected])
_git_submodule-ext ()
{
local subcommands="branch config-sync foreach list refresh set-url womp"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
case "$cur" in
-*)
__gitcomp "-h --help"
;;
*)
__gitcomp "$subcommands"
;;
esac
else
local foreach_opts="
--constrain --top-level --recursive --post-order
--include-staged --keep-going --no-cd --cd-orig
"
local foreach_posix_opts="-c -i -k -p -r -t"
local set_url_opts="--remote"
local set_url_subcommands="config repo super"
local refresh_opts="
--clear --dry-run --force --no-fetch --no-sync
--no-top-level-merge --no-track --remote --reset
"
local refresh_posix_opts="-f -N -n -T"
local all_opts="--help"
local all_opts_short="-h"
case "$subcommand,$cur,$prev" in
branch,--*,checkout)
__gitcomp "$all_opts"
;;
branch,-*,checkout)
__gitcomp "$all_opts_short"
;;
branch,*,checkout)
_git_checkout
;;
branch,--*,write)
__gitcomp "$all_opts"
;;
branch,-*,write)
__gitcomp "$all_opts_short"
;;
branch,*,write)
COMPREPLY=()
;;
branch,--*,*)
__gitcomp "$foreach_opts $all_opts"
;;
branch,-*,*)
__gitcomp "$foreach_posix_opts $all_opts_short"
;;
branch,*,*)
__gitcomp "checkout write"
;;
foreach,--*,*)
__gitcomp "$foreach_opts $all_opts"
;;
foreach,-*,*)
__gitcomp "$foreach_posix_opts $all_opts_short"
;;
list,--*,*)
__gitcomp "--constrain $all_opts"
;;
list,-*,*)
__gitcomp "-c $all_opts_short"
;;
set-url,--*,config)
__gitcomp "--set-gitmodules $foreach_opts $all_opts"
;;
set-url,-*,config)
__gitcomp "-g $foreach_posix_opts $all_opts_short"
;;
set-url,*,config)
COMPREPLY=()
;;
set-url,--*,repo)
__gitcomp "--no-sync --use-gitmodules $all_opts"
;;
set-url,-*,repo)
__gitcomp "-g -S $all_opts_short"
;;
set-url,*,repo)
COMPREPLY=()
;;
set-url,*,super)
COMPREPLY=()
;;
set-url,--*,*)
__gitcomp "$set_url_opts $foreach_opts $all_opts"
;;
set-url,-*,*)
__gitcomp "$foreach_posix_opts $all_opts_short"
;;
set-url,*,*)
__gitcomp "$set_url_subcommands"
;;
refresh,--*,*)
__gitcomp "$refresh_opts $foreach_opts $all_opts"
;;
refresh,-*,*)
__gitcomp "$refresh_posix_opts $foreach_posix_opts
$all_opts_short"
;;
refresh,*,*)
__gitcomp_nl "$(__git_refs '' $track)"
;;
*)
COMPREPLY=()
;;
esac
fi
}
_git_sube ()
{
_git_submodule-ext
}