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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11356 invoked from network); 18 Feb 2023 00:23:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Feb 2023 00:23:48 -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=jzkfaR4Q/LCMeEkxIxvLG+a6X47CdclhRi14D84ELCk=; b=KCnuvxYxSHydlsm0zySbfEVXzP y2ZEcoSoE9JePDp9/d42jzY7VUDoNyDHIbn4Ys7R0XQuURr0+Oa/iIEO+gzTXxY9KLTMPy2ajGJhF bBt3gMr3xyKouf/Ez2bClonSEOCY4G1vOm+yDgk+/SHQWAICQh735I2Oo84jFd8VtMo9ZA566HlGm jisrg2oPwQ7Mrwxm/N+x6ILiyoGvFRE9naVo4nEu98ve78zr0wssavMctq7cuumsgwOUGX9IDRWdi MSazglyavjuJQ4Gcv5Tn5tCM1FYJCr+v7RcT5Bc7seXoAc+fR9A6RWFkjhTwR6wc53HtxBH3BlnLH oNLE/srg==; Received: by zero.zsh.org with local id 1pTB11-000EEZ-C9; Sat, 18 Feb 2023 00:23:47 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pTB0k-000DwT-HS; Sat, 18 Feb 2023 00:23:30 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pTB0k-000NlV-4y for zsh-workers@zsh.org; Sat, 18 Feb 2023 01:23:30 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: complete only modified files with git add -u MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <91355.1676679810.1@hydra> Date: Sat, 18 Feb 2023 01:23:30 +0100 Message-ID: <91356-1676679810.150767@Ouz-.oJ2E.9I0C> X-Seq: 51456 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: This makes git completion skip new files after git add -u. In general, the option makes it easy to bulk update files without adding any new files but it is the sort of option that can be useful with completion specifically to limit the matches. I've also included a number of very minor _git updates that have been sitting in my tree for some while, there's a typo fix, a missing =, a prompt for function name after git blame -L and git blame --force has gained a short -f form. Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index a2555cbf0..49f9fa504 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -76,17 +76,21 @@ _git-add () { case $state in (file) - declare -a ignored_files_alternatives + declare -a file_alternatives + if [[ -z ${opt_args[(I)-u|--update]} ]]; then + file_alternatives=( + 'other-files::__git_ignore_line_inside_arguments __git_other_files' + ) + fi if [[ -n ${opt_args[(I)-f|--force]} ]]; then - ignored_files_alternatives=( + file_alternatives+=( 'ignored-modified-files:ignored modified file:__git_ignore_line_inside_arguments __git_modified_files --ignored' 'ignored-other-files:ignored other file:__git_ignore_line_inside_arguments __git_other_files --ignored') fi _alternative \ 'modified-files::__git_ignore_line_inside_arguments __git_modified_files' \ - 'other-files::__git_ignore_line_inside_arguments __git_other_files' \ - $ignored_files_alternatives && ret=0 + $file_alternatives && ret=0 ;; esac @@ -2365,7 +2369,7 @@ _git-worktree() { _arguments -S $endopt \ '(-n --dry-run)'{-n,--dry-run}"[don't remove, show only]" \ '(-v --verbose)'{-v,--verbose}'[report pruned objects]' \ - '--expire[expire objects older than specified time]:time' && ret=0 + '--expire=[expire objects older than specified time]:time' && ret=0 ;; (list) _arguments -S $endopt '--porcelain[machine-readable output]' && ret=0 @@ -2379,7 +2383,8 @@ _git-worktree() { ':location:_directories' && ret=0 ;; (remove) - _arguments -C -S $endopt '--force[remove working trees that are not clean or that have submodules]' \ + _arguments -C -S $endopt \ + '(-f --force)'{-f,--force}'[remove working trees that are not clean or that have submodules]' \ ': :->worktrees' && ret=0 ;; (unlock) @@ -3901,7 +3906,7 @@ _git-reflog () { ;; (delete) _arguments -C -S \ - '(-n --dry-run)'{-n,--dry-run}"[dpn't update entries; show what would be done]" \ + '(-n --dry-run)'{-n,--dry-run}"[don't update entries; show what would be done]" \ '--updateref[update ref with SHA-1 of top reflog entry after expiring or deleting]' \ '--rewrite[adjust reflog entries to ensure old SHA-1 points to new SHA-1 of previous entry after expiring or deleting]' \ '--verbose[output additional information]' \ @@ -4134,7 +4139,8 @@ _git-blame () { else _alternative \ 'line-numbers: :__git_guard_number "line number"' \ - 'regexes::_guard "(/[^/]#(\\?[^/]#)#(/|)|)" regex' && ret=0 + 'regexes::_guard "(/[^/]#(\\?[^/]#)#(/|)|)" regex' \ + 'functions::_guard "(|:*)" "function name"' && ret=0 fi ;; esac