From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21227 invoked from network); 28 Aug 2021 23:10:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Aug 2021 23:10:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:From:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=4BrI3npoNzahDoTborTLrVlWsjkLzLQIwuu2i1D8Vyc=; b=SaPWByw/Ms9QP9vVWzLSse2QRv MdW0plhZes0knGRCMn/5xIxiLkAOYZ6bXG7x0dv7ZbhJoH3e9D8Z1jNeCyyizpotH78QlYlqk75rF LyS+C9fIcQJr8gKKSl0xPSy6z+IpG2ek+8xAFtvwRbWh9tLjGYox551Q7m2hjfxHkcSACg6feblM6 itZppbp7yYGZiB1gAVE0RVCFbd5bIc1IdUdakC+V+BtBsAu9rkG1cHOjoTZRJt7wIzgLHvBrjtHW8 kARsYIIuQ/z4Oy9dsHNXxE5XTHZy4gCUQmjUSIXIfKimeb1pyUSSpozoZftufzQ6tLbsjhYvraRal FQWw5cnQ==; Received: from authenticated user by zero.zsh.org with local id 1mK7Sb-0000kp-Ki; Sat, 28 Aug 2021 23:10:01 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mK7SJ-0000R8-L7; Sat, 28 Aug 2021 23:09:43 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mK7SI-00030D-Cs for zsh-workers@zsh.org; Sun, 29 Aug 2021 01:09:42 +0200 From: Oliver Kiddle To: Zsh workers Subject: PATCH: complete for new git commands MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11543.1630192182.1@hydra> Date: Sun, 29 Aug 2021 01:09:42 +0200 Message-ID: <11544-1630192182.396253@PSaa.rHlE.E3WD> X-Seq: 49327 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: git has new maintenance, for-each-repo, sparse-checkout and bugreport commands. This adds completion for them. The first two facilitate things like running garbage collection from cron. Sparse checkouts allow for limited checkouts with just some files so you could checkout just the Completion directory from the zsh sources. Doesn't seem to be a way to avoid having the top-level directories in the checkout unfortunately. Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index de9c76fb1..dbea41d8c 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -641,6 +641,7 @@ _git-clone () { '(-4 --ipv4 -6 --ipv6)'{-6,--ipv6}'[use IPv6 addresses only]' \ '--filter=[object filtering]:filter:_git_rev-list_filters' \ '--remote-submodules[any cloned submodules will use their remote-tracking branch]' \ + '--sparse[initialize the sparse-checkout file to start with only the top-level files]' \ ': :->repository' \ ': :_directories' && ret=0 @@ -1215,6 +1216,46 @@ _git-log () { return ret } +(( $+functions[_git-maintenance] )) || +_git-maintenance() { + local curcontext="$curcontext" state state_descr line ret=1 + local -A opt_args + + _arguments -C \ + ': :->command' \ + '*::: := ->option-or-argument' && ret=0 + + case $state in + (command) + local -a commands + + commands=( + register:'initialize config values to run maintenance on this repository' + run:'run one or more maintenance tasks' + start:'start running maintenance on the current repository' + stop:'halt the background maintenance schedule' + unregister:'remove the current repository from background maintenance' + ) + + _describe -t commands command commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + (run) + _arguments -S $endopt \ + '--auto[run tasks based on the state of the repository]' \ + '--schedule=[run tasks based on frequency]:frequency (seconds)' \ + "--quiet[don't report progress or other information to stderr]" \ + '*--task=[run a specific task]:task:(gc commit-graph prefetch loose-objects incremental-repack pack-refs)' && ret=0 + ;; + esac + ;; + esac + + return ret +} + (( $+functions[_git-merge] )) || _git-merge () { local -a merge_options @@ -1732,6 +1773,50 @@ _git-show () { return ret } +(( $+functions[_git-sparse-checkout] )) || +_git-sparse-checkout() { + local curcontext="$curcontext" state state_descr line ret=1 + local -A opt_args + + _arguments -C \ + ': :->command' \ + '*::: := ->option-or-argument' && ret=0 + + case $state in + (command) + local -a commands + + commands=( + list:'describe the patterns in the sparse-checkout file' + init:'enable the core.sparseCheckout setting' + set:'write a set of patterns to the sparse-checkout file' + add:'update the sparse-checkout file to include additional patterns' + reapply:'reapply the sparsity pattern rules to paths in the working tree' + disable:'disable the config setting, and restore all files in the working directory' + ) + + _describe -t commands command commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + init) + _arguments \ + '--cone[allow for better performance with a limited set of patterns]' \ + '--no-sparse-index[rewrite index to not be sparse]' + ;; + set|add) + _arguments -S \ + '--stdin[read patterns from input]' \ + '*:pattern:_files' && ret=0 + ;; + esac + ;; + esac + + return ret +} + (( $+functions[_git-stash] )) || _git-stash () { local curcontext=$curcontext state line ret=1 @@ -4001,6 +4086,13 @@ _git-blame () { return ret } +(( $+functions[_git-bugreport] )) || +_git-bugreport() { + _arguments \ + '(-o --output-directory)'{-o+,--output-directory=}'[specify a destination for the bugreport file]:directory:_directories' \ + '(-s --suffix)'{-s+,--suffix=}'[specify a strftime format suffix for the filename]:format:_date_formats' +} + (( $+functions[_git-cherry] )) || _git-cherry () { # TODO: --abbrev is undocumented. @@ -4916,7 +5008,7 @@ _git-merge-index () { (( $+functions[_git-mktag] )) || _git-mktag () { - _message 'no arguments allowed; only accepts tags on standard input' + _arguments --no-strict } (( $+functions[_git-mktree] )) || @@ -5264,6 +5356,14 @@ _git-for-each-ref () { ':: :_guard "([^-]?#|)" pattern' } +(( $+functions[_git-for-each-repo] )) || +_git-for-each-repo() { + _arguments -S \ + '(-C --config)'{-C,--config=}'[specify config variable for list of paths]:config variable' \ + ':git command:_git_commands' \ + '*:: := _git' +} + (( $+functions[_git-ls-files] )) || _git-ls-files () { local no_empty_directory_opt= @@ -5965,6 +6065,7 @@ _git_commands () { gui:'run portable graphical interface to git' init:'create empty git repository or re-initialize an existing one' log:'show commit logs' + maintenance:'run tasks to optimize Git repository data' merge:'join two or more development histories together' mv:'move or rename file, directory, or symlink' notes:'add or inspect object notes' @@ -5978,6 +6079,7 @@ _git_commands () { rm:'remove files from the working tree and from the index' shortlog:'summarize git log output' show:'show various types of objects' + sparse-checkout:'initialize and modify the sparse-checkout' stash:'stash away changes to dirty working directory' status:'show working-tree status' submodule:'initialize, update, or inspect submodules' @@ -6001,6 +6103,7 @@ _git_commands () { ancillary_interrogator_commands=( blame:'show what revision and author last modified each line of a file' + bugreport:'collect information for user to file a bug report' count-objects:'count unpacked objects and display their disk consumption' difftool:'show changes using common diff tools' fsck:'verify connectivity and validity of objects in database' @@ -6035,7 +6138,7 @@ _git_commands () { index-pack:'build pack index file for an existing packed archive' merge-file:'run a three-way file merge' merge-index:'run merge for files needing merging' - mktag:'create tag object' + mktag:'create tag object with extra validation' mktree:'build tree-object from git ls-tree formatted text' multi-pack-index:'write and verify multi-pack-indexes' pack-objects:'create packed archive of objects' @@ -6054,6 +6157,7 @@ _git_commands () { diff-index:'compare content and mode of blobs between index and repository' diff-tree:'compare content and mode of blobs found via two tree objects' for-each-ref:'output information on each ref' + for-each-repo:'run a git command on a list of repositories' get-tar-commit-id:'extract commit ID from an archive created using git archive' ls-files:'information about files in index/working directory' ls-remote:'show references in a remote repository'