-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathstgit.zsh
More file actions
1768 lines (1564 loc) · 56.3 KB
/
stgit.zsh
File metadata and controls
1768 lines (1564 loc) · 56.3 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#compdef stg
# This script implements zsh completions for StGit (stg).
#
# To use these completions, copy to a directory in $fpath as _stgit.
# For example:
#
# $ mkdir ~/.zsh.d
# $ stg completion zsh >~/.zsh.d/_stgit
# $ $EDITOR ~/.zshrc
#
# fpath=("$HOME/.zsh.d" $fpath)
# autoload -U compinit
#
_stg-branch() {
local -a subcmd_args
local curcontext="$curcontext" state line
integer ret=1
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
': :->command'
'*:: :->option-or-argument'
)
_arguments -C $subcmd_args && ret=0
case $state in
(command)
declare -a commands switch_options
commands=(
{-l,--list}':list branches'
{-c,--create}':create and switch to new branch'
{-C,--clone}':clone current branch to new branch'
{-r,--rename}':rename existing branch'
{-p,--protect}':prevent stg from modifying branch'
{-u,--unprotect}':allow stg to modify branch'
{-D,--delete}':delete branch'
'--cleanup:cleanup stg metadata for branch'
{-d,--describe}':set branch description'
'--reset:soft reset the stack marking all patches as unapplied'
)
switch_options=(
'--merge:merge worktree changes into other branch'
)
_alternative \
'command: : _describe -t commands command commands' \
'switch-option: : _describe -t switch-options switch-option switch_options' \
'branch: : __stg_git_branch_names' && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]
case $line[1] in
(--cleanup)
_call_function ret _stg-branch-cleanup ;;
(-C|--clone)
_call_function ret _stg-branch-clone ;;
(-c|--create)
_call_function ret _stg-branch-create ;;
(-D|--delete)
_call_function ret _stg-branch-delete ;;
(-d|--describe|--description)
_call_function ret _stg-branch-describe ;;
(-l|--list)
_call_function ret _stg-branch-list ;;
(-p|--protect)
_call_function ret _stg-branch-protect ;;
(-r|--rename)
_call_function ret _stg-branch-rename ;;
(-u|--unprotect)
_call_function ret _stg-branch-unprotect ;;
# Options and arguments for the default command (switch branch).
(--merge)
_call_function ret _stg-branch-switch has-merge ;;
(*)
_call_function ret _stg-branch-switch has-branch ;;
esac
;;
esac
return ret
}
_stg-branch-switch() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
if [ "$1" != "has-merge" ]; then
subcmd_args+=('--merge[merge worktree changes into other branch]')
fi
if [ "$1" != "has-branch" ]; then
subcmd_args+=(':branch:__stg_git_branch_names')
fi
_arguments -S $subcmd_args
}
_stg-branch-cleanup() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'--force[force cleanup when series is non-empty]'
':stgit branch:__stg_stgit_branch_names'
)
_arguments -S $subcmd_args
}
_stg-branch-clone() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments $subcmd_args ':new-branch:'
}
_stg-branch-create() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments -s -S $subcmd_args ':new-branch:' ':committish:'
}
_stg-branch-delete() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'--force[force cleanup when series is non-empty]'
':branch:__stg_git_branch_names'
)
_arguments -s -S $subcmd_args
}
_stg-branch-describe() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments -s -S $subcmd_args ':description:' ':branch:__stg_git_branch_names'
}
_stg-branch-list() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments $subcmd_args
}
_stg-branch-protect() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments $subcmd_args ':branch:__stg_stgit_branch_names'
}
_stg-branch-rename() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
':old or new branch name:__stg_git_branch_names'
'::new branch name:__stg_git_branch_names'
)
_arguments $subcmd_args
}
_stg-branch-unprotect() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
_arguments $subcmd_args ':branch:__stg_stgit_branch_names'
}
_stg-clean() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'(-A --applied)'{-A,--applied}'[delete empty applied patches]'
'(-U --unapplied)'{-U,--unapplied}'[delete empty unapplied patches]'
)
_arguments -s -S $subcmd_args
}
_stg-commit() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'--allow-empty[allow committing empty patches]'
- group-all
'(-a --all)'{-a,--all}'[commit all applied patches]'
- group-number
'(-n --number)'{-n+,--number=}'[commit specified number of patches]:number'
- group-patches
'*:applied patches:__stg_dedup_inside_arguments __stg_patchrange --suggest-range --applied'
)
_arguments -s -S $subcmd_args
}
_stg-completion() {
local -a subcmd_args
local curcontext="$curcontext" state line
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
bash:'generate bash completion script'
fish:'generate fish shell completion script'
zsh:'generate zsh completion script'
list:'list StGit command information'
man:'generate asciidoc man pages'
help:'show help for given subcommand'
)
_describe -t commands 'completion command' command_list
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:stg-completion-$words[1]
if ! _call_function ret _stg-completion-$words[1]; then
_message "unknown subcommand: $words[1]"
fi
esac
return ret
}
_stg-completion-bash() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
)
_arguments -s -S $subcmd_args
}
_stg-completion-fish() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
)
_arguments -s -S $subcmd_args
}
_stg-completion-zsh() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
)
_arguments -s -S $subcmd_args
}
_stg-completion-man() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_directories'
)
_arguments -s -S $subcmd_args
}
_stg-completion-help() {
local -a subcmd_args
local curcontext="$curcontext" state line
subcmd_args+=(
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
bash:'generate bash completion script'
fish:'generate fish shell completion script'
zsh:'generate zsh completion script'
list:'list StGit command information'
help:'show help for given subcommand'
)
_describe -t commands 'completion command' command_list
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:stg-completion-$words[1]-help
_call_function ret _stg-completion-$words[1]-help
;;
esac
return ret
}
_stg-completion-list() {
local -a subcmd_args
local curcontext="$curcontext" state line
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
'--style=-[output format style]:style:(name-only fish zsh asciidoc)'
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
aliases:'list aliases'
commands:'list StGit commands'
commands-and-aliases:'list StGit commands and aliases'
help:'show help for given subcommand'
)
_describe -t commands 'completion command' command_list
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:stg-completion-list-$words[1]
if ! _call_function ret _stg-completion-list-$words[1]; then
_message "unknown subcommand: $words[1]"
fi
;;
esac
return ret
}
_stg-completion-list-help() {
local -a subcmd_args
local curcontext="$curcontext" state line
subcmd_args+=(
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
aliases:'list aliases'
commands:'list StGit commands'
commands-and-aliases:'list StGit commands and aliases'
help:'show help for given subcommand'
)
_describe -t commands 'completion command' command_list
;;
(option-or-argument)
;;
esac
return ret
}
_stg-completion-list-aliases() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
'--style=-[output format style]:style:(name-only fish zsh asciidoc)'
'--show-expansion[show alias expansion]'
)
_arguments -s -S $subcmd_args
}
_stg-completion-list-commands() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
'--style=-[output format style]:style:(name-only fish zsh asciidoc)'
)
_arguments -s -S $subcmd_args
}
_stg-completion-list-commands-and-aliases() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-o --output)'{-o,--output=}'[output to path]: :_files'
'--style=-[output format style]:style:(name-only fish zsh asciidoc)'
)
_arguments -s -S $subcmd_args
}
_stg-delete() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
__stg_add_args_push_conflicts
subcmd_args+=(
'--spill[spill patch contents to worktree and index]'
- group-ahu
'(-A --applied)'{-A,--applied}'[delete applied patches]'
'(-H --hidden)'{-H,--hidden}'[delete hidden patches]'
'(-U --unapplied)'{-U,--unapplied}'[delete unapplied patches]'
- group-all
'--all[delete all patches]'
- group-top
'(-t --top)'{-t,--top}'[delete top patch]'
- group-patchnames
'*:patches:__stg_dedup_inside_arguments __stg_patchrange --all'
)
_arguments -s -S $subcmd_args
}
_stg-diff() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_diffopt
subcmd_args+=(
'(-r --range)'{-r,--range=}'[show diff between revisions]: :__stg_patchrange --suggest-range --all'
'(-s --stat)'{-s,--stat}'[show stat instead of diff]'
'*:files:__stg_changed_files'
)
_arguments -s -S $subcmd_args
}
_stg-edit() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_author
__stg_add_args_edit
__stg_add_args_committer_date_is_author_date
__stg_add_args_hook
__stg_add_args_savetemplate
__stg_add_args_trailers
subcmd_args+=(
'(-d --diff)'{-d,--diff}'[edit patch diff]'
'(-t --set-tree)'{-t,--set-tree=}'[set git tree of patch]:treeish'
':patch:__stg_patch --all'
)
__stg_add_args_message
_arguments -s -S $subcmd_args
}
_stg-email() {
local -a subcmd_args
local curcontext="$curcontext" state line
__stg_add_args_help
__stg_add_args_color
subcmd_args+=(
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
format:'format patches as email files'
send:'send patches as emails'
help:'show help for given subcommand'
)
_describe -t commands 'email command' command_list
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:stg-email-$words[1]
if ! _call_function ret _stg-email-$words[1]; then
_message "unknown subcommand: $words[1]"
fi
;;
esac
return ret
}
_stg-email-format() {
local curcontext=$curcontext state line ret=1
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
subcmd_args+=(
'*'{-G+,--git-opt=}'[extra option for git-format-patch]:opt:__stg_git_format_patch_opts'
'(-o --output-directory)'{-o+,--output-directory=}'[store resulting files in given directory]: :_directories'
'(-n --numbered -N --no-numbered -k --keep-subject)'{-n,--numbered}'[name output in \[PATCH n/m\] format]'
'(-n --numbered -N --no-numbered -k --keep-subject)'{-N,--no-numbered}'[name output in \[PATCH\] format]'
'--start-number=[start numbering patches at given number]: :_numbers -l 1 "patch number"'
'--numbered-files[use only number for file name]'
'(-n --numbered -N --no-numbered -k --keep-subject --rfc --subject-prefix)'{-k,--keep-subject}"[don't strip/add \[PATCH\] from the first line of the commit message]"
'(-s --signoff)'{-s,--signoff}'[add Signed-off-by: trailer to the commit message]'
'( --inline)--attach[create attachments instead of inlining patches]'
'(--attach )--inline[inline patches]'
'(--thread )--no-thread[do not thread messages]'
'( --no-thread)--thread=-[make the second and subsequent mails refer to the first]::style:((shallow\:"all refer to the first"
deep\:"each refers to the previous"))'
'--in-reply-to=[make the first mail a reply to the given message]:message id'
'(-v --reroll-count)'{-v+,--reroll-count=}'[mark the series as the <n>-th iteration of the topic]: :_numbers iteration'
'(-k --keep-subject --subject-prefix)--rfc[use \[RFC PATCH\] instead of \[PATCH\]]'
'(-k --keep-subject --rfc)--subject-prefix=[use the given prefix instead of \[PATCH\]]:prefix'
'(--no-to)*--to=[add To: header to email headers]: :_email_addresses'
'--no-to[discard all To: headers added so far]'
'(--no-cc)*--cc=[add Cc: header to email headers]: :_email_addresses'
'--no-cc[discard all Cc: headers added so far]'
'*--add-header=[add an arbitrary header to email headers]:header' \
'--cover-letter[generate a cover letter]'
'( --no-signature --signature-file)--signature=[add a signature]:signature'
'(--signature --signature-file)--no-signature[do not add a signature]'
'(--signature --no-signature )--signature-file=[use contents of file as signature]: :_files'
'--base=[add prerequisite tree info to the patch series]:prereq commit:__stg_revisions'
'--suffix=[use the given suffix for filenames]:filename suffix'
'(-q --quiet)'{-q,--quiet}'[suppress the output of the names of generated files]'
'--no-binary[do not output contents of changes in binary files, only note that they differ]'
'--zero-commit[output all-zero hash in From header]'
'--progress[show progress while generating patches]'
'--interdiff=[insert interdiff against previous patch series in cover letter or single patch]:reference to tip of previous series:__stg_revisions'
'--range-diff=[insert range-diff against previous patch series in cover letter or single patch]:reference to tip of previous series:__stg_revisions'
'--creation-factor=[for range-diff, specify weighting for creation]:weighting (percent)'
+ '(sources)'
'(-a --all)'{-a,--all}'[format all applied patches]'
': :->patch-or-patch-range'
)
_arguments -s -S $subcmd_args && ret=0
case $state in
(patch-or-patch-range)
__stg_patchrange --suggest-range && ret=0
;;
esac
return ret
}
_stg-email-send() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
subcmd_args+=(
'*'{-G+,--git-opt=}'[extra option for git-send-email]:opt:__stg_git_send_email_opts'
'--from=[specify sender]:email address:_email_addresses'
'--to=[specify the primary recipient of the emails]: :_email_addresses'
'--cc=[starting Cc: value for each email]: :_email_addresses'
'--bcc=[Bcc: value for each email]: :_email_addresses'
'--subject=[specify the initial subject of the email thread]:subject'
'--reply-to=[specify Reply-To address]:email address:_email_addresses'
'--in-reply-to=[specify contents of first In-Reply-To header]:message-id'
'--compose[edit introductory message for patch series]'
'--annotate[review each patch in an editor]'
'--identity=[specify configuration identity]: :__stg_email_send_identities'
'--no-thread[do not set In-Reply-To: and References: headers]'
'--confirm[specify type of confirmation required before sending]: :((
always\:"always confirm before sending"
never\:"never confirm before sending"
cc\:"confirm before sending to automatically added Cc-addresses"
compose\:"confirm before sending first message when using --compose"
auto\:"same as cc together with compose"
))'
'--quiet[be less verbose]'
'--dry-run[do everything except actually sending the emails]'
+ '(sources)'
'(-a --all)'{-a,--all}'[send all applied patches]'
'(- *)--dump-aliases[dump configured aliases and exit]'
'*: : _alternative -O expl
"files:file:_files"
"patchrange::__stg_patchrange --suggest-range"'
)
_arguments -s -S $subcmd_args
}
_stg-email-help() {
local -a subcmd_args
local curcontext="$curcontext" state line
subcmd_args+=(
'(-): :->command'
'(-)*:: :->option-or-argument'
)
integer ret=1
_arguments -s -S $subcmd_args && ret=0
case $state in
(command)
local -a command_list=(
format:'format patches as email files'
send:'send patches as emails'
help:'show help for given subcommand'
)
_describe -t commands 'email command' command_list
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:stg-email-$words[1]-help
_call_function ret _stg-email-$words[1]-help
;;
esac
return ret
}
_stg-export() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
__stg_add_args_diffopt
subcmd_args+=(
'(-d --dir)'{-d,--dir}'[export patches to directory]: :_directories'
'(-n --numbered)'{-n,--numbered}'[prefix patch names with order numbers]'
'(-s --stdout)'{-s,--stdout}'[dump patches to standard output]'
'(-t --template)'{-t,--template=}'[use template file]: :_files'
'*:patches:__stg_dedup_inside_arguments __stg_patchrange'
+ '(suffix)'
'(-e --extension)'{-e,--extension=}'[extension to append to patch names]:extension'
'(-p --patch)'{-p,--patch}'[append .patch to patch names]'
)
_arguments -s -S $subcmd_args
}
_stg-files() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'--bare[bare file names]'
'(-s --stat)'{-s,--stat}'[show diff stat]'
':patches:__stg_patch --all'
)
_arguments -s -S $subcmd_args
}
_stg-float() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_keep
__stg_add_args_committer_date_is_author_date
subcmd_args+=(
'--noapply[Reorder patches by floating without applying]'
'(-S --series)'{-S,--series=}'[arrange according to series file]: :_files'
'*:patches:__stg_dedup_inside_arguments __stg_patchrange --all'
)
_arguments -s -S $subcmd_args
}
_stg-fold() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'(-b --base)'{-b,--base=}'[apply on base commit instead of HEAD]:commit'
'(-p --strip)'{-p+,--strip=}'[remove N leading directories from diff paths]:num'
'-C=[ensure N lines of surrounding context for each change]:num'
'--reject[leave rejected hunks in .rej files]'
':file:_files'
)
_arguments -s -S $subcmd_args
}
_stg-goto() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_keep
__stg_add_args_merged
__stg_add_args_committer_date_is_author_date
__stg_add_args_push_conflicts
subcmd_args+=(
':patches:__stg_patch --all'
)
_arguments -s -S $subcmd_args
}
_stg-help() {
_arguments -s ':commands:__stg_subcommands'
}
_stg-hide() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
subcmd_args+=(
'*:patches:__stg_dedup_inside_arguments __stg_patchrange'
)
_arguments -s -S $subcmd_args
}
_stg-id() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
subcmd_args+=(
':references:__stg_patch --all'
)
_arguments -s -S $subcmd_args
}
_stg-import() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_author
__stg_add_args_edit
__stg_add_args_committer_date_is_author_date
__stg_add_args_trailers
subcmd_args+=(
'(-n --name)'{-n,--name}'[name for imported patch]'
'(-p --strip)'{-p+,--strip=}'[remove N leading directories from diff paths]:num'
'--directory[prepend root to all filenames]:root:_directories'
'(-t --stripname)'{-t,--stripname}'[strip number and extension from patch name]'
'-C=[ensure N lines of surrounding context for each change]:num'
'(-3 --3way)'{-3,--3way}'[attempt three-way merge]'
'(-i --ignore)'{-i,--ignore}'[ignore applied patches in series]'
'--replace[replace unapplied patches in series]'
'--reject[leave rejected hunks in .rej files]'
'--keep-cr[do not remove CR from email lines ending with CRLF]'
'--message-id[create Message-ID trailer from email header]'
'(-d --showdiff)'{-d,--showdiff}'[show patch content in editor buffer]'
':file:_files'
+ '(source)'
'(-m --mail)'{-m,--mail}'[import from standard email file]'
'(-M --mbox)'{-M,--mbox}'[import from mbox file]'
'(-S --series)'{-S,--series}'[import from series file]'
'(-u --url)'{-u,--url}'[import patch from URL]'
)
_arguments -s -S $subcmd_args
}
_stg-init() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
_arguments -s $subcmd_args
}
_stg-log() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
subcmd_args+=(
'--clear[clear log history]'
'(-d --diff)'{-d,--diff}'[show refresh diffs]'
'(-f --full)'{-f,--full}'[show full commit ids]'
'(-g --graphical)'{-g,--graphical}'[show log in gitk]'
'(-n --number)'{-n+,--number=}'[limit to number of commits]'
'*:patches:__stg_dedup_inside_arguments __stg_patchrange --all'
)
_arguments -s -S $subcmd_args
}
_stg-new() {
local curcontext=$curcontext state line ret=1
local -a subcmd_args
declare -A opt_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_edit
__stg_add_args_author
__stg_add_args_trailers
__stg_add_args_hook
__stg_add_args_savetemplate
subcmd_args+=(
'(-d --diff)'{-d,--diff}'[show diff when editing patch message]'
'(-n --name)'{-n,--name=}'[name for new patch]:patchname'
'(-r --refresh)'{-r,--refresh}'[refresh new patch]'
'(-F --force)'{-F,--force}'[force refresh even if index is dirty]'
'(-i --index)'{-i,--index}'[refresh from index instead of worktree]'
'(-)--[start file arguments]: :->modified-file'
)
if [[ $words[(I)--] = "0" && ${words[(I)-n|--name(=*|)]} = "0" ]]; then
subcmd_args+=(':: :_guard "([^-]?#|)" patchname')
fi
__stg_add_args_message
_arguments -C -s $subcmd_args && ret=0
case $state in
(modified-file)
__stg_dedup __stg_modified_files && ret=0
;;
esac
return ret
}
_stg-next() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
_arguments -s -S $subcmd_args
}
_stg-patches() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
__stg_add_args_diffopt
subcmd_args+=(
'(-d --diff)'{-d,--diff}'[show diffs of given files]'
'*:files:__stg_cached_files'
)
_arguments -s -S $subcmd_args
}
_stg-pick() {
local -a subcmd_args
# TODO: complete --parent commit id
__stg_add_args_help
__stg_add_args_committer_date_is_author_date
subcmd_args+=(
'(-n --name)'{-n,--name=}'[name for picked patch]:name'
'(-B --ref-branch)'{-B,--ref-branch=}'[pick patches from branch]: :__stg_stgit_branch_names'
'(-r --revert)'{-r,--revert}'[revert given commit object]'
'(-p --parent=)'{-p,--parent}'[use commit id as parent]:commit'
'(-x --expose)'{-x,--expose}'[append imported commit id to patch log]'
'--noapply[keep patch unapplied]'
'*'{-f,--file=}'[only fold given file]: :_files'
'*:patches:__stg_dedup_inside_arguments __stg_patchrange --use-ref-branch'
+ '(mode)'
'--fold[fold the commit into current patch]'
'--update[fold limited to current patch files]'
)
_arguments -s -S $subcmd_args
}
_stg-pop() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_keep
subcmd_args+=(
'(-s --spill)'{-s,--spill}'[pop a patch keeping its modifications in the tree]'
- group-number
'(-n --number)'{-n+,--number=}'[push specified number of patches]:number'
- group-all
'(-a --all)'{-a,--all}'[push all unapplied patches]'
- group-patches
'*:applied patches:__stg_dedup_inside_arguments __stg_patchrange --applied'
)
_arguments -s -S $subcmd_args
}
_stg-prev() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_branch
_arguments -s -S $subcmd_args
}
_stg-pull() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_merged
__stg_add_args_push_conflicts
subcmd_args+=(
'(-n --nopush)'{-n,--nopush}'[do not push patches after rebasing]'
':repository:__stg_remotes'
)
_arguments -s -S $subcmd_args
}
_stg-push() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_keep
__stg_add_args_merged
__stg_add_args_committer_date_is_author_date
__stg_add_args_push_conflicts
subcmd_args+=(
'--reverse[push patches in reverse order]'
'--noapply[push without applying]'
'--set-tree[push patch with the original tree]'
- group-all
'(-a --all)'{-a,--all}'[push all unapplied patches]'
- group-number
'(-n --number)'{-n+,--number=}'[push specified number of patches]:number'
- group-patches
'*:unapplied patches:__stg_dedup_inside_arguments __stg_patchrange --unapplied'
)
_arguments -s -S $subcmd_args
}
_stg-rebase() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_merged
__stg_add_args_committer_date_is_author_date
__stg_add_args_push_conflicts
subcmd_args+=(
'(-n --nopush)'{-n,--nopush}'[do not push patches after rebasing]'
'(-i --interactive)'{-i,--interactive}'[interactively manipulate patches in editor]'
'--autostash[Stash changes before rebase and reapply them after]'
':new-base-id:__stg_heads'
)
_arguments -s -S $subcmd_args
}
_stg-redo() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'--hard[discard changes in index/worktree]'
'(-n --number)'{-n+,--number=}'[number of undos to redo]:number'
)
_arguments -s -S $subcmd_args
}
_stg-refresh() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_color
__stg_add_args_author
__stg_add_args_edit
__stg_add_args_committer_date_is_author_date
__stg_add_args_hook
__stg_add_args_trailers
__stg_add_args_diffopt
__stg_add_args_push_conflicts
subcmd_args+=(
'(-a --annotate)'{-a,--annotate=}'[annotate patch log entry]:note'
'(-d --diff)'{-d,--diff}'[show diff when editing patch message]'
'(-F --force)'{-F,--force}'[force refresh even if index is dirty]'
'(-i --index)'{-i,--index}'[refresh from index instead of worktree]'
'(-p --patch)'{-p,--patch=}'[refresh patch other than top patch]: :__stg_patch --all'
'--spill[Spill patch contents to worktree and index, and erase patch content]'
+ '(update-files)'
'(-u --update)'{-u,--update}'[only update current patch files]'
'*:files:__stg_modified_files'
+ '(submodules)'
'(-s --submodules)'{-s,--submodules}'[include submodules in refresh]'
'--no-submodules[exclude submodules from refresh]'
)
__stg_add_args_message
_arguments -s -S $subcmd_args
}
_stg-rename() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
__stg_add_args_color
subcmd_args+=(
':old-patch:__stg_patch --all'
':new patch name:'
)
_arguments -s -S $subcmd_args
}
_stg-repair() {
local -a subcmd_args
__stg_add_args_help
_arguments -s $subcmd_args
}
_stg-reset() {
local -a subcmd_args
__stg_add_args_help
subcmd_args+=(
'--hard[discard changes in index/worktree]'
':state:'
'*:patches:__stg_dedup_inside_arguments __stg_patchrange --all'
)
_arguments -s -S $subcmd_args
}
_stg-series() {
local -a subcmd_args
__stg_add_args_help
__stg_add_args_branch
__stg_add_args_color
subcmd_args+=(
'--author[display the author name for each patch]'
'(-c --count)'{-c,--count}'[print number of patches]'
'(-i --commit-id)'{-i,--commit-id}=-'[display commit ids]::length'
'(-d --description)'{-d,--description}'[display short descriptions]'
'(-e --empty)'{-e,--empty}'[identify empty patches]'
'(-I --indices)'{-I,--indices}'[display absolute indices of patches]'
'(-m --missing)'{-m,--missing=}'[show patches from branch missing in current]: :__stg_stgit_branch_names'
'(-O --offsets)'{-O,--offsets}'[display relative offsets of patches]'
'--prefix[display patch status prefix]'
'(-P --no-prefix)'{-P,--no-prefix}'[do not display the patch status prefix]'
'(-r --reverse)'{-r,--reverse}'[display in reverse order]'
'(-s --short)'{-s,--short}'[list just patches around the topmost patch]'
'--showbranch[display branch name of listed patches]'
'--no-author[do not display patch author]'
'--no-commit-id[do not display commit ids]'
'--no-description[do not display patch descriptions]'