Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Feb 16, 2025
1 parent 082c422 commit ac08e67
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 26 deletions.
8 changes: 8 additions & 0 deletions share/completion/git
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ function completion/git::--format:arg {
esac
}

function completion/git::--gpg-sign:arg {
# TODO
}

function completion/git::--ignore-submodules:arg { #>>#
complete -P "$PREFIX" -D "ignore all changes in submodules" all
complete -P "$PREFIX" -D "ignore uncommitted changes in submodules" dirty
Expand Down Expand Up @@ -781,6 +785,10 @@ function completion/git::--shallow-exclude:arg {
command -f completion/git::completeref
}

function completion/git::--sort:arg {
# TODO
}

function completion/git::--untracked-files:arg { #>>#
complete -P "$PREFIX" -D "print all individual files in untracked directories" all
complete -P "$PREFIX" -D "print untracked files and directories" normal
Expand Down
5 changes: 3 additions & 2 deletions share/completion/git-am
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function completion/git::am:arg {
(--patch-format)
complete -P "$PREFIX" mbox mboxrd stgit stgit-series hg
;;
#(S|--gpg-sign)
# TODO ;;
(S|--gpg-sign)
command -f completion/git::--gpg-sign:arg
;;
(*)
if command -vf completion/git::apply:compopt >/dev/null 2>&1 ||
. -AL completion/git-apply; then
Expand Down
7 changes: 2 additions & 5 deletions share/completion/git-branch
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function completion/git::branch:arg {
"--set-upstream; like --track, but don't move HEAD"
"u: --set-upstream-to:; set the upstream to the specified one"
"--show-current; show the current branch name"
"--sort:; sort branches"
"--sort:; specify the sort order"
"t:: --track::; create a remote-tracking branch"
"--unset-upstream; remove the upstream"
"v --verbose; print commit ID and summary for each branch"
Expand All @@ -56,7 +56,7 @@ function completion/git::branch:arg {
;;
(--abbrev)
;;
(--color|--column)
(--color|--column|--sort)
command -f completion/git::$ARGOPT:arg
;;
(--format)
Expand All @@ -65,9 +65,6 @@ function completion/git::branch:arg {
(u|--set-upstream-to)
command -f completion/git::completeref --remotes
;;
(--sort)
#TODO
;;
(t|--track) #>>#
complete -P "$PREFIX" -D "use start-point branch as upstream" direct
complete -P "$PREFIX" -D "copy remote-tracking branch from start-point branch" inherit
Expand Down
3 changes: 3 additions & 0 deletions share/completion/git-cherry-pick
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function completion/git::cherry-pick:arg {
complete -P "$PREFIX" -D 'create empty commits for redundant patches' -- keep
complete -P "$PREFIX" -D 'pause on redundant patches' -- stop
;; #<<#
(S|--gpg-sign)
command -f completion/git::--gpg-sign:arg
;;
# (m|--mainline)
# ;;
(X|--strategy*)
Expand Down
3 changes: 3 additions & 0 deletions share/completion/git-commit
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ function completion/git::commit:arg {
([Cc]|--fixup|--reuse-message|--reedit-message|--squash)
command -f completion/git::completeref
;;
(S|--gpg-sign)
command -f completion/git::--gpg-sign:arg
;;
(u|--untracked-files)
command -f completion/git::--untracked-files:arg
;;
Expand Down
53 changes: 49 additions & 4 deletions share/completion/git-format-patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011 magicant
# (C) 2011-2025 magicant

# Completion script for the "git-format-patch" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1.

function completion/git-format-patch {
WORDS=(git format-patch "${WORDS[2,-1]}")
Expand All @@ -12,32 +12,54 @@ function completion/git::format-patch:arg {

OPTIONS=( #>#
"--add-header:; specify an additional header string"
"--always; produce patches even for empty commits"
"--attach::; make patch contents an mail attachment"
"--base:; insert base commit info"
"--cc:; specify an additional receiver"
"--cover-from-description:; specify which part of cover letter is auto-filled"
"--cover-letter; create a file containing overall diffstat"
"--creation-factor:; specify the creation factor for the range-diff"
"--description-file:; specify a file containing the cover letter"
"--encode-email-headers; encode non-ASCII email headers"
"--filename-max-length:; specify the maximum length of the filenames"
"--force-in-body-from; always output an in-body 'From:' line"
"--from::; specify the email sender"
"--ignore-if-in-upstream"
"--inline::; like --attach, but use \"Content-Disposition: inline\""
"--in-reply-to:"
"--interdiff:; specify a revision to compare with and produce an interdiff"
"k --keep-subject; don't add/remove \"[PATCH]\""
"--no-attach; cancel the --attach option"
"--no-base; don't insert base commit info"
"--no-binary; don't include diffs for binary files"
"p --no-stat; create plain patches without diffstats"
"--no-cover-letter; don't create a cover letter"
"--no-encode-email-headers; keep non-ASCII email headers as-is"
"--no-force-in-body-from; cancel the --force-in-body-from option"
"--no-notes; don't append notes for each commit"
"N --no-numbered; name output in \"[PATCH]\" format"
"--no-signature; don't append a signature to results"
"p --no-stat; create plain patches without diffstats"
"--notes::; append notes for each commit"
"--no-thread; don't thread mails"
"n --numbered; name output in \"[PATCH n/m]\" format"
"--numbered-files; use simple integers for output filenames"
"o: --output-directory:; specify the directory to place the results in"
"--quiet; don't print created patch filenames"
"--progress; report progress"
"q --quiet; don't print created patch filenames"
"--range-diff:; specify a revision to compare with and produce a range-diff"
"v: --reroll-count:; mark patches with a specified version"
"--rfc::; prepend an additional subject prefix"
"--root; treat the operand as a revision range"
"--signature:; specify a signature appended to each message"
"--signature-file:; specify a file containing a signature"
"s --signoff; include a signed-off-by line"
"--start-number:; specify a number to start numbering patches from"
"--stdout; output results to the standard output rather than files"
"--subject-prefix:; specify a string prefix to the subject"
"--suffix:; specify a suffix appended to result filenames"
"--thread::; specify mail threading behavior"
"--to:; specify an additional receiver"
"--zero-commit; replace commit hashes with zeros"
) #<#
if command -vf completion/git::diff:getopt >/dev/null 2>&1 ||
. -AL completion/git-diff; then
Expand All @@ -53,13 +75,36 @@ function completion/git::format-patch:arg {
;;
(--attach|--inline)
;;
(--base)
complete -P "$PREFIX" auto
command -f completion/git::completeref
;;
(--cover-from-description) #>>#
complete -P "$PREFIX" -D "auto-fill message body" message default
complete -P "$PREFIX" -D "auto-fill message subject and body" subject
complete -P "$PREFIX" -D "based on description length" auto
complete -P "$PREFIX" none
;; #<<#
(--in-reply-to)
;;
(--interdiff|--range-diff)
command -f completion/git::completeref
;;
(--notes)
command -f completion/git::completeref \
abbrprefixes=refs/notes/ dontcompletefull=true \
--glob=refs/notes/\*
;;
(o|--output-directory)
complete -P "$PREFIX" -S / -T -d
;;
(--rfc)
;;
(--signature)
;;
(--signature-file)
complete -P "$PREFIX" -f
;;
(--start-number)
;;
(--subject-prefix)
Expand Down
7 changes: 5 additions & 2 deletions share/completion/git-grep
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2013-2018 magicant
# (C) 2013-2025 magicant

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

function completion/git-grep {
WORDS=(git grep "${WORDS[2,-1]}")
Expand Down Expand Up @@ -36,11 +36,13 @@ function completion/git::grep:arg {
"i --ignore-case; case-insensitive matching"
"L --files-without-match; print only the names of files containing no selected lines"
"l --files-with-matches --name-only; print filenames only"
"m: --max-count:; limit the number of matches per file"
"--max-depth:; specify directory depth to limit search"
"n --line-number; print line numbers"
"--no-color; like --color=never"
"--no-exclude-standard; search ignored files"
"--no-index; search files outside a working tree"
"--no-recursive; only search the operand directory"
"--not; negate a pattern"
"--no-textconv; ignore textconv settings"
"O:: --open-files-in-pager::; open matching files in a pager"
Expand All @@ -49,6 +51,7 @@ function completion/git::grep:arg {
"p --show-function; print the name of the function containing the match"
"P --perl-regexp; use Perl's regular expression"
"q --quiet; don't print anything to the standard output"
"r --recursive; search subdirectories recursively"
"--recurse-submodules; search submodules as well"
"--textconv; honor textconv settings"
"--threads:; specify the number of worker threads"
Expand Down
13 changes: 11 additions & 2 deletions share/completion/git-init
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011 magicant
# (C) 2011-2025 magicant

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

function completion/git-init {
WORDS=(git init "${WORDS[2,-1]}")
Expand All @@ -12,7 +12,10 @@ function completion/git::init:arg {

OPTIONS=( #>#
"--bare; create a bare repository"
"b: --initial-branch:; specify the initial branch name"
"--object-format:; specify a hash algorithm for objects"
"q --quiet; print error and warning messages only"
"--ref-format:; specify a ref storage format"
"--separate-git-dir:; specify the repository directory"
"--shared::; share the repository with other users"
"--template:; specify a directory that contains templates"
Expand All @@ -35,6 +38,12 @@ function completion/git::init:arg {

function completion/git::init:compopt
case $ARGOPT in
(--object-format) #>>#
complete -P "$PREFIX" sha1 sha256
;; #<<#
(--ref-format) #>>#
complete -P "$PREFIX" files reftable
;; #<<#
(--shared) #>>#
complete -P "$PREFIX" -D "set permissions according to the current umask" umask false
complete -P "$PREFIX" -D "make the repository group-writable" group true
Expand Down
13 changes: 10 additions & 3 deletions share/completion/git-log
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011-2016 magicant
# (C) 2011-2025 magicant

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

function completion/git-log {
WORDS=(git log "${WORDS[2,-1]}")
Expand Down Expand Up @@ -31,15 +31,19 @@ function completion/git::log:arg {
function completion/git::log:getopt {
OPTIONS=("$OPTIONS" #>#
"--bisect; show commits between good and bad only"
"--clear-decorations; decorate with the default set of refs"
"--decorate::; show ref names of commits"
"--decorate-refs::; only decorate with refs that match the given pattern"
"--decorate-refs-exclude::; only decorate with refs that don't match the given pattern"
"--follow; show history beyond filename renaming"
"--full-diff; show diffs for all files affected in each commit"
"L:; specify a range in a file to trace history"
"--log-size; print its size before printing log messages"
"--mailmap --use-mailmap; canonicalize authors, committers and emails"
"--no-decorate; like --decorate=no"
"--no-mailmap --no-use-mailmap; cancel the --mailmap option"
"--source; show from which ref each commit was reached"
"t; show tree objects in the diff"
"--use-mailmap; canonicalize authors, committers and emails"
) #<#
if command -vf completion/git::rev-list:getopt >/dev/null 2>&1 ||
. -AL completion/git-rev-list; then
Expand All @@ -59,6 +63,9 @@ function completion/git::log:compopt
complete -P "$PREFIX" -D "show ref names without prefixes" short
complete -P "$PREFIX" -D "don't show ref names" no
;; #<<#
(--decorate-refs*)
command -f completion/git::completeref
;;
(L)
case $TARGETWORD in (?*:*)
typeset w="${TARGETWORD#?*:}"
Expand Down
18 changes: 13 additions & 5 deletions share/completion/git-ls-remote
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2013 magicant
# (C) 2013-2025 magicant

# Completion script for the "git-ls-remote" command.
# Supports Git 1.8.1.4.
# Supports Git 2.48.1.

function completion/git-ls-remote {
WORDS=(git ls-remote "${WORDS[2,-1]}")
Expand All @@ -11,18 +11,26 @@ function completion/git-ls-remote {
function completion/git::ls-remote:arg {

OPTIONS=( #>#
"b h --branches --heads; print branches only"
"--exit-code; return a non-zero exit status if no refs were printed"
"--get-url; just print remote URL"
"--heads; print branches only"
"--tags; print tags only"
"u: --upload-pack:; specify a path for git-upload-pack on the remote host"
"q --quiet; don't print remote URL"
"--refs; only show real refs"
"o: --server-option:; specify a server option"
"--sort:; specify the sort order"
"--symref; also show intermediate symbolic refs"
"t --tags; print tags only"
"--upload-pack:; specify a path for git-upload-pack on the remote host"
) #<#

command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--sort)
command -f completion/git::--sort:arg
;;
(u|--upload-pack)
command -f completion/git::--upload-pack:arg
;;
Expand Down
Loading

0 comments on commit ac08e67

Please sign in to comment.