File: git-worktree

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (202 lines) | stat: -rw-r--r-- 6,413 bytes parent folder | download
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# (C) 2016-2025 magicant

# Completion script for the "git-worktree" command.
# Supports Git 2.48.1.

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

function completion/git::worktree:arg
        if [ ${WORDS[#]} -le 1 ]; then #>>#
                complete -P "$PREFIX" -D "create a new worktree" add
                complete -P "$PREFIX" -D "clean up info for deleted worktrees" prune
                complete -P "$PREFIX" -D "show worktree status" list
                complete -P "$PREFIX" -D "prevent a worktree from being pruned" lock
                complete -P "$PREFIX" -D "move a worktree" move
                complete -P "$PREFIX" -D "remove a worktree" remove
                complete -P "$PREFIX" -D "recover worktree metadata" repair
                complete -P "$PREFIX" -D "unlock a worktree" unlock
        else #<<#
                WORDS=("${WORDS[2,-1]}")
                if command -vf "completion/git::worktree:${WORDS[1]}:arg" >/dev/null 2>&1; then
                        command -f "completion/git::worktree:${WORDS[1]}:arg"
                fi
        fi

function completion/git::worktree:add:arg {

        OPTIONS=( #>#
        "B:; create or reset a new branch and check it out"
        "b:; create a new branch and check it out"
        "--checkout; check out the branch in the new worktree"
        "--detach; leave HEAD in detached head state"
        "f --force; allow multiple working trees for a single branch"
        "--guess-remote; guess which remote to use for a new branch"
        "--lock; keep the working tree locked"
        "--no-checkout; don't check out the branch in the new worktree"
        "--no-guess-remote; don't create a new branch from a remote"
        "--no-relative-paths; save worktrees with absolute paths"
        "--no-track; create a non-tracking branch"
        "--orphan; create a new branch with no parent"
        "q --quiet; print error messages only"
        "--reason:; specify a reason for locking the working tree"
        "--relative-paths; save worktree paths relative to the main tree"
        "t --track; create a tracking branch"
        ) #<#

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ([Bb])
                        command -f completion/git::completeref --branches
                        ;;
#                (--track)
#                        command -f completion/git::--track:arg
#                        ;;
                ('')
                        command -f completion//getoperands
                        case ${WORDS[#]} in
                                (0)
                                        complete -P "$PREFIX" -S / -T -d
                                        ;;
                                (1)
                                        command -f completion/git::completeref
                                        ;;
                        esac
                        ;;
        esac

}

function completion/git::worktree:list:arg {

        OPTIONS=( #>#
        "--expire:; annotate missing worktrees older than the specified time"
        "--porcelain; print in the machine-friendly format"
        "v --verbose; print lock reasons as well"
        "z; use NUL as separator"
        ) #<#

        command -f completion//parseoptions -n
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        ;;
        esac

}

function completion/git::worktree:lock:arg {

        OPTIONS=( #>#
        "--reason:; specify a reason for locking the working tree"
        ) #<#

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        complete -P "$PREFIX" -S / -T -d
                        ;;
        esac

}

function completion/git::worktree:move:arg {

        OPTIONS=()

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        command -P "$PREFIX" -S / -T -d
                        ;;
        esac

}

function completion/git::worktree:prune:arg {

        OPTIONS=( #>#
        "--expire:; specify age of working trees to remove"
        "n --dry-run; don't remove anything, just report"
        "v --verbose; report removed working trees"
        ) #<#

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                (--expire)
                        # TODO complete date
                        ;;
        esac

}

function completion/git::worktree:remove:arg {

        OPTIONS=( #>#
        "--force; remove even if the worktree is dirty"
        ) #<#

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        complete -P "$PREFIX" -S / -T -d
                        ;;
        esac

}

function completion/git::worktree:repair:arg {

        OPTIONS=( #>#
        "--no-relative-paths; save worktrees with absolute paths"
        "--relative-paths; save worktree paths relative to the main tree"
        ) #<#

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        complete -P "$PREFIX" -S / -T -d
                        ;;
        esac

}

function completion/git::worktree:unlock:arg {

        OPTIONS=()

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        complete -P "$PREFIX" -S / -T -d
                        ;;
        esac

}

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