Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Feb 17, 2025
1 parent ac08e67 commit 25888d6
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 25 deletions.
6 changes: 6 additions & 0 deletions share/completion/git
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ function completion/git::--date:arg { #>>#
} #<<#
# TODO --date=format:...%

function completion/git::--empty:arg { #>>#
complete -P "$PREFIX" -D 'discard redundant patches' drop
complete -P "$PREFIX" -D 'create empty commits for redundant patches' keep
complete -P "$PREFIX" -D 'pause on redundant patches' stop
} #<<#

function completion/git::--format:arg {
typeset word="${TARGETWORD#"$PREFIX"}"
word=${word//%%}
Expand Down
3 changes: 3 additions & 0 deletions share/completion/git-am
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function completion/git::am:arg {
('')
complete -P "$PREFIX" -f
;;
(--empty)
command -f completion/git::--empty:arg
;;
(--patch-format)
complete -P "$PREFIX" mbox mboxrd stgit stgit-series hg
;;
Expand Down
8 changes: 3 additions & 5 deletions share/completion/git-cherry-pick
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ function completion/git::cherry-pick:arg {
(--cleanup)
command -f completion/git::--cleanup:arg
;;
(--empty) #>>#
complete -P "$PREFIX" -D 'ignore redundant patches' -- drop
complete -P "$PREFIX" -D 'create empty commits for redundant patches' -- keep
complete -P "$PREFIX" -D 'pause on redundant patches' -- stop
;; #<<#
(--empty)
command -f completion/git::--empty:arg
;;
(S|--gpg-sign)
command -f completion/git::--gpg-sign:arg
;;
Expand Down
13 changes: 6 additions & 7 deletions share/completion/git-name-rev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2012 magicant
# (C) 2012-2025 magicant

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

function completion/git-name-rev {
WORDS=(git name-rev "${WORDS[2,-1]}")
Expand All @@ -13,10 +13,12 @@ function completion/git::name-rev:arg {
OPTIONS=( #>#
"--all; print all commits reachable from any refs"
"--always; show uniquely abbreviated commit object as fallback"
"--exclude:; do not consider refs matching the given glob"
"--name-only; don't print SHA-1 before each name"
"--no-exclude; cancel all previous --exclude options"
"--no-undefined; exit with non-zero status for an undefined reference"
"--refs:; specify refs that should be used by a pattern"
"--stdin; filter the standard input, appending a name to each SHA-1"
"--annotate-stdin --stdin; filter the standard input, appending a name to each SHA-1"
"--tags; use tag names only"
) #<#

Expand All @@ -25,10 +27,7 @@ function completion/git::name-rev:arg {
(-)
command -f completion//completeoptions
;;
(--refs)
command -f completion/git::completeref
;;
('')
(*)
command -f completion/git::completeref
;;
esac
Expand Down
11 changes: 9 additions & 2 deletions share/completion/git-notes
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-notes" command.
# Supports Git 2.6.2.
# Supports Git 2.48.1.

function completion/git-notes {
WORDS=(git notes "${WORDS[2,-1]}")
Expand Down Expand Up @@ -43,10 +43,15 @@ function completion/git::notes:add:arg {
OPTIONS=( #>#
"C: --reuse-message:; specify a blob used as the note message"
"c: --reedit-message:; like -C, but reedit the message"
"e --edit; edit the note message"
"F: --file:; specify a file containing the note message"
"f --force; overwrite existing note"
"m: --message:; specify a note message"
"--allow-empty; allow an empty note"
"--no-separator; don't insert a separator"
"--no-stripspace; leave leading and trailing spaces and blank lines"
"--separator::; specify a inter-paragraph separator"
"--stripspace; remove leading and trailing spaces and blank lines"
) #<#

command -f completion//parseoptions
Expand Down Expand Up @@ -91,6 +96,8 @@ function completion/git::notes:edit:arg {

OPTIONS=( #>#
"--allow-empty; allow an empty note"
"--no-stripspace; leave leading and trailing spaces and blank lines"
"--stripspace; remove leading and trailing spaces and blank lines"
) #<#

command -f completion//parseoptions
Expand Down
14 changes: 10 additions & 4 deletions share/completion/git-pull
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-pull" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1.

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

OPTIONS=( #>#
"--no-rebase; cancel the --rebase option"
"--no-rebase; don't rebase but merge"
"q --quiet; don't report progress"
"--rebase; rebase the current branch instead of merging"
"r:: --rebase::; rebase the current branch instead of merging"
"v --verbose" # TODO description
) #<#
if command -vf completion/git::fetch:getopt >/dev/null 2>&1 ||
Expand All @@ -36,6 +36,12 @@ function completion/git::pull:arg {
;;
# (--depth)
# ;;
(r|--rebase) #>>#
complete -P "$PREFIX" -D "don't rebase but merge" false
complete -P "$PREFIX" -D "rebase" true
complete -P "$PREFIX" -D "rebase recreating merge commits" merges
complete -P "$PREFIX" -D "rebase interactively" interactive
;; #<<#
('')
command -f completion//getoperands
if [ ${WORDS[#]} -eq 0 ]; then
Expand Down
26 changes: 22 additions & 4 deletions share/completion/git-push
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011-2014 magicant
# (C) 2011-2025 magicant

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

function completion/git-push {
WORDS=(git push "${WORDS[2,-1]}")
Expand All @@ -11,24 +11,34 @@ function completion/git-push {
function completion/git::push:arg {

OPTIONS=( #>#
"--all; push all local branches"
"--delete; delete remote refs specified as operands"
"4 --ipv4; use IPv4 addresses only"
"6 --ipv6; use IPv6 addresses only"
"--atomic; update all remote refs atomically"
"--branches --all; push all local branches"
"d --delete; delete remote refs specified as operands"
"n --dry-run; don't actually push anything"
"--follow-tags; push reachable annotated tags as well"
"f --force; allow non-fast-forward update"
"--force-if-includes; force only if the current remote has been locally integrated"
"--force-with-lease::; like --force, but prevent unexpected history loss"
"--mirror; push all local refs"
"--no-atomic; don't require atomic updates"
"--no-force-if-includes; cancel the --force-if-includes option"
"--no-force-with-lease; cancel the --force-with-lease option"
"--no-recurse-submodules; don't push submodules"
"--no-signed; don't GPG-sign the push request"
"--no-thin; cancel the --thin option"
"--no-verify; disable the pre-push hook"
"--porcelain; print in the machine-friendly format"
"--progress; report progress"
"--prune; delete remote branches that have no local counterparts"
"o: --push-option:; send the specified option to the remote"
"q --quiet; don't report progress"
"--repo:; specify the default repository to push to"
"--receive-pack: --exec:; specify a path for git-receive-pack on the remote host"
"--recurse-submodules:; ensure submodule commits are available on the remote"
"u --set-upstream; make pushed branches remote-tracking"
"--signed::; GPG-sign the push request"
"--tags; push all local tags"
"--thin; send a thin pack to reduce traffic"
"v --verbose; output additional information"
Expand All @@ -52,6 +62,9 @@ function completion/git::push:arg {
(--recurse-submodules) #>>#
complete -P "$PREFIX" -D "check if submodules have been pushed" check
complete -P "$PREFIX" -D "push submodules as necessary" on-demand
complete -P "$PREFIX" -D "push submodules but not the supermodule"
only
complete -P "$PREFIX" -D "don't push submodules" no
;; #<<#
(--repo|'')
command -f completion//getoperands
Expand All @@ -76,6 +89,11 @@ function completion/git::push:arg {
esac
fi
;;
(--signed) #>>#
complete -P "$PREFIX" -D "always sign" true
complete -P "$PREFIX" -D "never sign" false
complete -P "$PREFIX" -D "sign if supported by the server" if-asked
;; #<<#
esac

}
Expand Down
17 changes: 14 additions & 3 deletions share/completion/git-rebase
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011-2019 magicant
# (C) 2011-2025 magicant

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

function completion/git-rebase {
WORDS=(git rebase "${WORDS[2,-1]}")
Expand Down Expand Up @@ -32,29 +32,36 @@ function completion/git::rebase:getopt {
OPTIONS=("$OPTIONS" #>#
"--abort; abort the current rebasing and reset to the original"
"--allow-empty-message"
"--apply; use git-am internally"
"--autosquash; find commits to be squashed (with -i)"
"--autostash; stash before and restore after rebasing"
"--committer-date-is-author-date; use author date for committer date"
"--continue; continue the current rebasing"
"--edit-todo; re-edit the to-do list of the current rebasing"
"--empty:; specify how to handle commits that become empty"
"f --force-rebase --no-ff; create new commits without fast-forwarding"
"--fork-point; use reflog to find a better common ancestor"
"--ignore-date; use committer date for author date"
"--ignore-date --reset-author-date; reset author date to current time"
"i --interactive; interactively reedit commits that are rebased"
"--keep-base; apply commits starting from the same merge base"
"--keep-empty; don't omit commits that make no change"
"m --merge; use merging strategies to rebase"
"--no-autosquash; cancel the --autosquash option"
"--no-autostash; cancel the --autostash option"
"--no-fork-point; ignore reflog when finding a better common ancestor"
"--no-gpg-sign; don't sign commits with GPG"
"--no-keep-empty; omit commits that make no change"
"--no-reapply-cherry-picks; drop cherry-picks from the upstream"
"--no-reschedule-failed-exec"
"--no-rerere-autoupdate; disable the rerere mechanism"
"n --no-stat; don't print a diffstat"
"--no-update-refs; don't update other branches"
"--no-verify; don't run the pre-rebase hook"
"--onto; specify a branch to rebase onto"
# Deprecated "p --preserve-merges; don't ignore merge commits"
"q --quiet; don't print anything"
"--quit; end suspended rebasing and keep the current state"
"--reapply-cherry-picks; keep cherry-picks from the upstream"
"r --rebase-merges::; recreate merge commits"
"--rerere-autoupdate; enable the rerere mechanism"
"--reschedule-failed-exec"
Expand All @@ -67,6 +74,7 @@ function completion/git::rebase:getopt {
"s: --strategy:; specify the merge strategy"
"x: --exec:; insert an \"exec\" line with the specified command after each commit (with -i)"
"X: --strategy-option:; specify a strategy-specific option"
"--update-refs; update other branches to point at the rebased commits"
"v --verbose; output additional information"
"--verify; run the pre-rebase hook"
) #<#
Expand All @@ -78,6 +86,9 @@ function completion/git::rebase:getopt {

function completion/git::rebase:compopt
case $ARGOPT in
(--empty)
command -f completion/git::--empty:arg
;;
(--rebase-merges)
complete -P "$PREFIX" no-rebase-cousins rebase-cousins
;;
Expand Down

0 comments on commit 25888d6

Please sign in to comment.