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=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1588 invoked from network); 10 Feb 2023 07:25:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2023 07:25:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1676013935; b=US6FN67g8aG+bPth8/F7TFCY9+N0meXZUkbBaj8O4dSeOEM+Cft9Kqmt8NKD3fULRJ5NioThqa IDxo4kaBTXT2sQyayvNH5TXh/p3XW1ch9tk72uMWdiwrD/iYoGye+GhqXdbuyGjS/LPRhRGrXS m2EQmtXhbqIX7eWPR8JfqlvasCZxqBKbp/bh7Y+begnWnYQJ/XAKWsKGNryWSKwB7OBhV5F0gR o/Oquz60y/M0qUYmbGOMw38lX4nbW7KQkdPeiEIzJSG7KgetU3T7V5RifIisnfKz6pU84Pu0XE 7onEesQkvnbc7iOMOfGItUKcSCuMcWqC+fTZNiwdkDGKiQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1676013935; bh=Y2d/+p9m+YEpiatLxDQwiWkgz0ou6+TBbM/1wlH011s=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:DKIM-Signature:DKIM-Signature; b=cERke2NGxddcP/e5Bz3oZ42FFfAGe1eiTvmv32865HgcbEEvX6Ss82MHU/08BrTC19IpCE+q/a eiBkK05SE6dfd9YvsCSRrhxpbZT4ojC3lLyApUjU6E3mfTDLmYq5zybukfOInQTcMCKR2o8YhX 9PLsRf1EKEi1zQ5hlgUWQm3baZVq0lyyhxVfU/kbQgc9oOiexn/YOEqpQZbMWI6T+/Anc1Djcp TdvamenX0zlLYpZz2DPCVlOxDTAJScQCLLtkTFqL4q0J0IkLdScJqkgAirt9PF6R0gsZbYhY5X oGnTU/at5AhOZ+TZbAPxtGXvDOf3m3Ma24EcMDVDF9PHPA==; 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:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=5VnfGaSRCN7Fd79okfwLVxNz+5PElt0tSgp46/m3uog=; b=LyBGu+WbAX/QuF9SCi7iWpCMK7 DzTv46Q34jSGdr9yvDQXSjMtew2LDKf4Zg1al2bAVt1iMnnDs5rJMcOxxTA9LtbqlZvyFlSfNWhM7 IqfE9PfuCqdXpeQYktMWJphVT8PZIzT9rZoopoO6I/dL2//jRs9wgKbh0ZgSnoMzI7v6S8w5hZEIB LKet3IS/m7DRZr6n6HepU4orZs+Nnh2iK/4P1iS0aa3cudUKS+Rh6+xcuzrPh2Mw9IiWZDhpkhG5w KZlTPiqPGI/NQ3StFiWnG95k9xT5nSZjS77jx6pREjGAljoSCNh0Z4yHeCG4gyDJwhj3zy76cvHsv spjILXrA==; Received: by zero.zsh.org with local id 1pQNmn-0001RL-DJ; Fri, 10 Feb 2023 07:25:33 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f42.google.com ([209.85.218.42]:45890) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pQNmU-000188-P0; Fri, 10 Feb 2023 07:25:15 +0000 Received: by mail-ej1-f42.google.com with SMTP id dr8so13334686ejc.12 for ; Thu, 09 Feb 2023 23:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5VnfGaSRCN7Fd79okfwLVxNz+5PElt0tSgp46/m3uog=; b=cv94J+iNRPAoQYeSLevs2jU54puwIKTeNAj5DX0SscfmlrMsKB79xGVHdswl3FSg9S LUQ2HM6VYwZJ+v2UUL/iESgJTchAO9RfrSiQVc+q3dzYAUi87Q6RONq4OUZGnSmyK0nH ciceIW7A3KYiJ5A3Il/mQ0lDeQ31huu6zgbCDm/10MbUaUpRIM9OcfwSY2k3qWadMFe3 cbeMWveKHBv6b4jLt0uy9RVB2PhQhO6Acdw02g3c+GXlK8OfT4EiIkJt39qKEcr068HZ NOuu7NQkWufq9xusv/GVn7kQhGxA9QWnG/ctRLErncCHnkf11y+xWm3Su9A1/EcrjDTy gihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5VnfGaSRCN7Fd79okfwLVxNz+5PElt0tSgp46/m3uog=; b=3s8aE2KTO4qLzxIawSsHlZJvc6M9bSAglpDiZEjaznrOokuF/dFMxLBt7FAXypoABC SiMpm0Jlgovw9ko3N2+Zm/gWLXseTrNB/eQg4wgS/rLo96kwd8v8QI9YgkwKBnG5NU66 Xi9hiAcnWOB4kp49iHiEahruQPf8sst6/P/aN//LmW/syGEjvS4WDt8b4ODlc/P0kpYb sQYSPQ2NCX5B2RhQdE9XT7aKZ2OjOuE4D+kuQYV1HGObxIX2Su2zUsNxS4YuES5VOf0U Rl2kcXSz2W/Pk54ero/jJc4JGEzXA+mvHMqHwdkATkLn/l5OWpzStE2vS6iWLF23Fx1k B5rQ== X-Gm-Message-State: AO0yUKWhlUm0tsGIlY5mnwwd3t5sX9hDJ+e1CI2yesABCOGxjsb0y2SB BTjJzOCptDoTsZWC7u3duSX2Wz3vhaM= X-Google-Smtp-Source: AK7set/KTREToV+Cx74rIPlHl9lBWKsc4d0fTppHocLGamTXZCsrCO34n0DTojFyXc0+lF7Ex0F7dQ== X-Received: by 2002:a17:906:7097:b0:888:94d3:37f5 with SMTP id b23-20020a170906709700b0088894d337f5mr13406033ejk.63.1676013913852; Thu, 09 Feb 2023 23:25:13 -0800 (PST) Received: from localhost.localdomain ([2001:4641:9d1:0:9c74:f016:4c88:53bb]) by smtp.gmail.com with ESMTPSA id t18-20020a50c252000000b0049148f6461dsm1767174edf.65.2023.02.09.23.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 23:25:13 -0800 (PST) From: =?UTF-8?q?=C3=98ystein=20Walle?= To: zsh-workers@zsh.org Cc: =?UTF-8?q?=C3=98ystein=20Walle?= Subject: [PATCH] _git-push: complete remote branch names respecting --delete Date: Fri, 10 Feb 2023 08:23:01 +0100 Message-Id: <20230210072301.30349-1-oystwa@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 51391 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: If you want to delete the branch foo from origin and type: git push --delete origin f it might get completed as: git push --delete origin origin/foo which will lead Git into erroring out saying the remote ref doesn't exist. If -d or --delete is given on the command line then complete remote branches without their prefix, otherwise proceed as before. --- Completion/Unix/Command/_git | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index b3ed7b5c8..a2555cbf0 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1459,6 +1459,14 @@ _git-push () { # only complete files on the local end, not the remote end. Still, it may be # helpful to get some sort of completion going, perhaps modifying the path # later on to match the remote end. + + local ref_arg + if (( words[(I)-d|--delete] )); then + ref_arg='*: :__git_remote_branch_names_noprefix' + else + ref_arg='*: :__git_ref_specs_pushy' + fi + _arguments -S -s $endopt \ '--all[push all refs under refs/heads/]' \ '--prune[remove remote branches that do not have a local counterpart]' \ @@ -1494,7 +1502,7 @@ _git-push () { '(-4 --ipv4 -6 --ipv6)'{-4,--ipv4}'[use IPv4 addresses only]' \ '(-4 --ipv4 -6 --ipv6)'{-6,--ipv6}'[use IPv6 addresses only]' \ ': :__git_any_repositories' \ - '*: :__git_ref_specs_pushy' && ret=0 + $ref_arg && ret=0 case $state in (lease) -- 2.20.1