Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Feb 19, 2025
1 parent 67d9994 commit d73988e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
11 changes: 10 additions & 1 deletion share/completion/git
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,9 @@ function completion/git::--date:arg { #>>#
complete -P "$PREFIX" -D "print in strict ISO 8601 format" iso8601-strict
complete -P "$PREFIX" -D "print in RFC 2822 format" rfc2822
complete -P "$PREFIX" -D "print in YYYY-MM-DD format" short
complete -P "$PREFIX" -D "print the raw timestamp value" raw
complete -P "$PREFIX" -D "print the raw timestamp value with offset" raw
complete -P "$PREFIX" -D "print in minimal human-readable format" human
complete -P "$PREFIX" -D "print the raw timestamp value" unix
complete -P "$PREFIX" local relative-local default-local iso8601-local \
iso8601-strict-local rfc2822-local short-local raw-local
complete -P "$PREFIX" -D "specify a format" -T format:
Expand All @@ -685,6 +687,12 @@ function completion/git::--empty:arg { #>>#
complete -P "$PREFIX" -D 'pause on redundant patches' stop
} #<<#

function completion/git::--exclude-hidden:arg { #>>#
complete -P "$PREFIX" -D "fetch.hideRefs" fetch
complete -P "$PREFIX" -D "receive.hideRefs" receive
complete -P "$PREFIX" -D "uploadpack.hideRefs" uploadpack
} #<<#

function completion/git::--format:arg {
typeset word="${TARGETWORD#"$PREFIX"}"
word=${word//%%}
Expand Down Expand Up @@ -741,6 +749,7 @@ function completion/git::--format:arg {
complete -P "$PREFIX" -D "commit ID, author, date, and full log message" medium
complete -P "$PREFIX" -D "commit ID, author, committer, and full log message" full
complete -P "$PREFIX" -D "commit ID, author, date, committer, date, and full log message" fuller
complete -P "$PREFIX" -D "commit ID, title, and date" reference
complete -P "$PREFIX" -D "imitate email" email
complete -P "$PREFIX" -D "raw commit object" raw
complete -P "$PREFIX" -D "specify a format (newline-separated)" -T format:
Expand Down
55 changes: 48 additions & 7 deletions share/completion/git-rev-list
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-rev-list" command.
# Supports Git 2.9.2.
# Supports Git 2.48.1.

function completion/git-rev-list {
WORDS=(git rev-list "${WORDS[2,-1]}")
Expand All @@ -14,12 +14,25 @@ function completion/git::rev-list:arg {
"--bisect; print a midpoint commit in current bisect"
"--bisect-all"
"--bisect-vars"
"--commit-header; show commit IDs for each commit"
"--count; print the number of selected commits only"
"--disk-usage::; show storage size used by selected commits"
"--filter:; show commits that match the specified criteria only"
"--filter-print-omitted; mark filtered objects in the output"
"--filter-provided-objects; apply --filter to provided objects"
# for internal use only: "--exclude-promisor-objects"
"--header; print commits in the raw format"
"--in-commit-order; print trees and blobs in commit order"
"--indexed-objects; print object IDs referenced by the index"
"--missing:; specify how to handle missing objects"
"--no-commit-header; suppress lines showing commit IDs"
"--no-filter; cancel the --filter option"
"--no-object-names; don't print object names"
"--object-names; print object names (with --objects)"
"--objects; print object IDs referenced by selected commits"
"--objects-edge; like --objects, but print excluded commits too"
"--objects-edge-aggressive; like --objects-edge, but more slow and accurate"
"--indexed-objects; print object IDs referenced by the index"
"--progress:; show progress"
"--timestamp; print the raw timestamp values"
"--unpacked; print object IDs that are not in packs"
) #<#
Expand All @@ -45,9 +58,9 @@ function completion/git::rev-list:getopt {
command -f completion/git::getprettyopts
command -f completion/git::getrefselectopts
OPTIONS=("$OPTIONS" #>#
"--ancestry-path; show commits on the ancestor-descendant path only"
"--ancestry-path::; show commits on the ancestor-descendant path only"
"--all-match; show commits that match all the other filter options only"
"--after: --since:; show commits after the specified date only"
"--alternate-refs; show refs of alternate repositories"
"--author:; show commits by the specified author only"
"--basic-regexp; use basic regular expression"
"--before: --until:; show commits before the specified date only"
Expand All @@ -60,6 +73,8 @@ function completion/git::rev-list:getopt {
"--date:; specify a date format"
"--dense; show commits that have a diff"
"--do-walk; traverse commit ancestors"
"--exclude-first-parent-only; don't exclude commits merged from topic branches"
"--exclude-hidden:; apply hideRefs to exclude refs"
"E --extended-regexp; use extended regular expression"
"--first-parent; follow first parent of each commit only"
"F --fixed-strings; perform simple string matching rather than regular expression"
Expand All @@ -83,7 +98,7 @@ function completion/git::rev-list:getopt {
"--no-min-parents; like --min-parents=0"
"--no-walk::; don't traverse commit ancestors"
"--parents; print parents' commit IDs as well"
"--perl-regexp; use Perl's regular expression"
"P --perl-regexp; use Perl's regular expression"
"--quiet; print nothing"
"i --regexp-ignore-case; case-insensitive regular expression matching"
"--reflog; show all reflogs"
Expand All @@ -92,8 +107,12 @@ function completion/git::rev-list:getopt {
"--reverse; print in reverse order"
"--right-only; show commits on the right-hand-side branch only"
"--show-linear-break::; show a separator between branches"
"--show-pulls" # TODO description
"--simplify-by-decoration; show branch/tag heads only"
"--simplify-merges; don't show merges that re-merge an ancestor"
"--since: --after:; stop at the first commit after the specified date"
"--since-as-filter:; show commits after the specified date only"
"--single-worktree; show commits in the current worktree only"
"--sparse; show all walked commits"
"--stdin; read arguments from the standard input"
"--use-bitmap-index"
Expand All @@ -105,7 +124,7 @@ function completion/git::rev-list:getopt {

function completion/git::rev-list:compopt
case $ARGOPT in
(n|--max-*|--min-*)
(n|--max-*|--min-*|--progress)
# complete nothing
;;
(--author|--date)
Expand All @@ -121,6 +140,28 @@ function completion/git::rev-list:compopt
done 2>/dev/null \
<(git log --all --format=format:%cn | uniq)
;;
(--disk-usage) #>>#
complete -P "$PREFIX" -D "human-readable" human
;; #<<#
(--exclude-hidden)
command -f completion/git::--exclude-hidden:arg
;;
(--filter) #>>#
complete -P "$PREFIX" -D "omit all blobs" blob:none
complete -P "$PREFIX" -S = -T -D "show blobs smaller than the specified size" blob:limit
complete -P "$PREFIX" -D "show tags only" object:type=tag
complete -P "$PREFIX" -D "show commits only" object:type=commit
complete -P "$PREFIX" -D "show trees only" object:type=tree
complete -P "$PREFIX" -D "show blobs only" object:type=blob
complete -P "$PREFIX" -S = -T -D "show blobs for sparse checkout only" sparse:oid
complete -P "$PREFIX" -S : -T -D "omit blobs deeper than the specified level" tree
;; #<<#
(--missing) #>>#
complete -P "$PREFIX" -D "stop on missing objects" error
complete -P "$PREFIX" -D "ignore missing objects" allow-any
complete -P "$PREFIX" -D "ignore expected missing objects" allow-promisor
complete -P "$PREFIX" -D "mark missing objects" print
;; #<<#
(--no-walk)
complete -P "$PREFIX" sorted unsorted
;;
Expand Down
25 changes: 23 additions & 2 deletions share/completion/git-rev-parse
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2016 magicant
# (C) 2016-2025 magicant

# Completion script for the "git-rev-parse" command.
# Supports Git 2.9.2.
# Supports Git 2.48.1.

function completion/git-rev-parse {
WORDS=(git rev-parse "${WORDS[2,-1]}")
Expand All @@ -12,31 +12,40 @@ function completion/git::rev-parse:arg {

OPTIONS=( #>#
"--abbrev-ref::; print in short object names"
"--absolute-git-dir; print the absolute path of the repository"
"--after: --since:; convert the specified date to --max-age timestamp"
"--before: --until:; convert the specified date to --mim-age timestamp"
"--default; specify a default argument"
"--disambiguate:; show all SHA-1 values that start with the specified prefix"
"--end-of-options"
"--exclude-hidden:; apply hideRefs to exclude refs"
"--flags; print options only"
"--git-common-dir; print the main repository path"
"--git-dir; print the repository path"
"--git-path; resolve a path inside the repository"
"--is-bare-repository; test if the repository is bare"
"--is-inside-git-dir; test if the current directory is inside a repository"
"--is-inside-work-tree; test if the current directory is inside a working tree"
"--is-shallow-repository; test if the repository is shallow"
"--keep-dashdash"
"--local-env-vars; print repository-local environment variables"
"--no-flags; print operands only"
"--no-revs; ignore arguments meant for rev-list"
"--not; negate printed object names"
"--output-object-format:; convert object IDs to the specified format"
"--parseopt; enable option parsing mode"
"--path-format:"
"--prefix; specify a directory to operate in"
"q --quiet; don't print any error message (with --verify)"
"--show-ref-format; print the ref format used in the current repository"
"--resolve-git-dir; test if the operand is a repository path"
"--revs-only; ignore arguments not meant for rev-list"
"--shared-index-path; print the shared index file path"
"--short::; abbreviate printed SHA-1 values"
"--show-cdup; print a relative path to the top-level directory"
"--show-object-format:; print the object format used in the current repository"
"--show-prefix; print a relative path from the top-level directory"
"--show-superproject-working-tree; print the path to the superproject working tree"
"--show-toplevel; print the absolute path of the top-level directory"
"--sq; print with shell-friendly quotation"
"--sq-quote; enable shell quoting mode"
Expand All @@ -59,6 +68,18 @@ function completion/git::rev-parse:arg {
complete -P "$PREFIX" -D "allow ambiguous names" loose
complete -P "$PREFIX" -D "ensure unambiguous names" strict
;; #<<#
(--exclude-hidden)
command -f completion/git::--exclude-hidden:arg
;;
(--output-object-format) #>>#
complete -P "$PREFIX" sha1 sha256 storage
;; #<<#
(--path-format) #>>#
complete -P "$PREFIX" absolute relative
;; #<<#
(--show-object-format) #>>#
complete -P "$PREFIX" storage input output
;; #<<#
('')
command -f completion/git::completerefpath range=true
;;
Expand Down

0 comments on commit d73988e

Please sign in to comment.