From patchwork Mon Jan 29 13:27:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13535653 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CF5B64CE4 for ; Mon, 29 Jan 2024 13:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534888; cv=none; b=O8AXwpwrZHee1X70SkKa/7Wr+xKl9y3Ec79zd6TAXXiiE1ou/GTwwJRld+8bd+nyHFUAgzrpxwUI3i8WPIltBMAfwZ25rl1ymBjNl92RpaDeQep8RZ8P3tMFCG+gIhPt7yo2a9ei8L4YaZ7W7vAOM2O+dGLj+ZHTktb1O482cqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534888; c=relaxed/simple; bh=lvMxwpu5SITz45OThYK9Sw30XiLRRcYvW3f6jY6Cpqc=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=N0F8C+qcziNDs+vVIW7S7wr3/849XgxmaxcvHcwMCLLUcMXLSnIvZ5OrgCyF6csDf3HjNCtjU677SHff6nt0ktu2RIXp6je/AVu46K8vxJmLw8gWpp2xQ9h68qgTXrrKklLLkEkAk4j7XZk0oVN2vDnokoSHYhwPaj7MUSdYw1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y3sAD4fw; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y3sAD4fw" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51032058f17so1633442e87.3 for ; Mon, 29 Jan 2024 05:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706534884; x=1707139684; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=XXyWyvBibm9hTSLDiYgyRvra4RZZ/TOhpEDNI9Sq/xo=; b=Y3sAD4fw8zHJR/fEAQrFypTUBn3jY4kWyye+zXrYUyZB/ByUUMxR/Bp45jicpsnYhq 4kBQGR88lJTL3zP9Ll1UuqnY/IRZX8p2toRj37OsB9epKXndypdSE3UDuayyM6MeVfBe gqKoIC+7QcvGcb0RDh2XLGfTKU94kt4ZqXPtOVWKAq0bTc2Pww+L7ub5PRSwATHGb3+f SiG4jqYIWULkO34cjVxoRxEbHSM3la8pOwUAFcjpy5uZ91j3YiSc3lr0ToEnRDA0tWFV x03kCf5H7vOsoGzWrFFqNOvT6zXVChJBpBbFrv66Z4IEt+c4GW8HngrkZ7YL51a3r4im RNbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706534884; x=1707139684; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XXyWyvBibm9hTSLDiYgyRvra4RZZ/TOhpEDNI9Sq/xo=; b=Gh/7qC40u0o9e4nT48bVWmIZJqxlFKXV4hoz2rhStJ2+kYM7i1UYP5zMZRoTe+tuPl VwiR0XjclYD/9li8jFBMHzlpgHGu7CHjJQwZIgOpHGgUzQwhnzoE9sykveI0NZ8e3M4z FucUFhRWJnGU3NyYNHh+8qZTaZGQiY+dDhVWNEtcvDm2BdCF5MWy8RX1MkHS5ZV8S1sy PDupPWHVt9jWCWc0QntgG3O2fgzL64YOOB0T+XYOBqtTTzsyXPbYPPnYkL1dUr6Mr9sq qSXtJFHAGeU9c6kUs22lUlEJ6cybVCIgPlzI7o9DL4+t7dd7UvmVmKhggCb7+s5OIf2+ 4bRQ== X-Gm-Message-State: AOJu0YzgMJkTPYXirhUOLDlytM/fe2zid63oENSjZYI652SO4y9z/xg7 H1Rz1rDPNTxs2+ru0ZxBJVfs871e8KhKL0nb6SGwsGIsTpwtPJKps2bf513v X-Google-Smtp-Source: AGHT+IF9li1dss0YchDlMl6u1PCNDHR3+bxWKH0CoGNPz0SndnGr0Qe7xD06BR/xS2GxkOKfPZ33RQ== X-Received: by 2002:a05:6512:3192:b0:510:1878:9f00 with SMTP id i18-20020a056512319200b0051018789f00mr3990935lfe.64.1706534884041; Mon, 29 Jan 2024 05:28:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id fa7-20020a05600c518700b0040ec6d7420csm13956920wmb.14.2024.01.29.05.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:28:03 -0800 (PST) Message-ID: <837d92a6c277015fc8633ca84557124465390548.1706534882.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Jan 2024 13:27:57 +0000 Subject: [PATCH v2 1/5] completion: add space after config variable names also in Bash 3 Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In be6444d1ca (completion: bash: add correct suffix in variables, 2021-08-16), __git_complete_config_variable_name was changed to use "${sfx- }" instead of "$sfx" as the fourth argument of _gitcomp_nl and _gitcomp_nl_append, such that this argument evaluates to a space if sfx is unset. This was to ensure that e.g. git config branch.autoSetupMe[TAB] correctly completes to 'branch.autoSetupMerge ' with the trailing space. This commits notes that the fix only works in Bash 4 because in Bash 3 the 'local sfx' construct at the beginning of __git_complete_config_variable_name creates an empty string. Make the fix also work for Bash 3 by using the "unset or null' parameter expansion syntax ("${sfx:- }"), such that the parameter is also expanded to a space if it is set but null, as is the behaviour of 'local sfx' in Bash 3. Signed-off-by: Philippe Blain --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6662db221df..159a4fd8add 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2750,7 +2750,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }" return ;; guitool.*.*) @@ -2784,7 +2784,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __git_compute_all_commands - __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }" return ;; remote.*.*) @@ -2800,7 +2800,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }" return ;; url.*.*) From patchwork Mon Jan 29 13:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13535654 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FE6064CF5 for ; Mon, 29 Jan 2024 13:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534889; cv=none; b=nSBynh/g1YJWndKf1bmDRK4vdB0FLllwR2iCAq/cJJBUqgBglFPZ5b98HFGhxPnpSWBkTUlYJ8xEoP5EcjTj6EjQP4fadbrkdvuJ6hdUd/Cs1pQbFKpb7WEELeqzftc1WcJx6IGQZUunii6yQANKQLJckh8iWSFjMkAIoVnOXrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534889; c=relaxed/simple; bh=NJ7EfKMPw7p7pie7Luy2Gunpy4YTA3WctlBUTJwjwB4=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=e6IVuIFaa7z71z5t2U6VXFIfXXbHyP3rmc+8f2CqCV6XKTaA2GffGbhgLIeOt743swN6YRZ1bWU5buakZ3MT8ws2rdt92G83KyJUXLRU6m9N0eBlyQ67lkNcoKelAkoClQkHLdDs0+BoBqXRGns6D5AE+rCaVfprE4q9V7liA3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HltqOJbb; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HltqOJbb" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-33af4b34e2cso277050f8f.1 for ; Mon, 29 Jan 2024 05:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706534884; x=1707139684; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LEW5FFJmSym+dBGzrMen0xCyW3bGwpQfsoLaATumYJE=; b=HltqOJbbhUckCadawzMW+k9co2wf9lV/12UXkApcp11UwtZ1Z+6C11lyhW0Hyp6KHs 6AFcnugfHKFH6Rw25/4R+BHEzNCdKRGZU6Nio/mNw7aNkVEjXOOT0X7sR1jk5J/xR9CI aF4O9H1NSgP0Eo/kKqQxmklVPWj+Ul5W2ksRQKiE3SCsAbs9L6qLKH4fKQCczkIbce2q f/7mABJ+qGiYcfmQ522oWnhAl65RIyyNsuY6DFWTQO10ykaRez7lR9RkikwnnvcOiNdF z7d/rWPy53/CN15FUTvPTPkalyIveoZk7ir8xEyAXyTxpI9tLJPwEw6x5/5wAfiT2y3X rDag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706534884; x=1707139684; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LEW5FFJmSym+dBGzrMen0xCyW3bGwpQfsoLaATumYJE=; b=DKH/4bwCezIVhlbOzLO+wByGOdqA4QCY+Exns+gRtBUJo9VjR9dj39VSfj+ABfQ5R/ ArP20eqNgmPEx5/xOyAwM3j2ohCGCKrsweDPC4tG/27QP7Z3heBQEBs4pZsPHICKuJ7J AkfSnNg7xfd3dcxSa5DGlrRA74S2yUIclGKumaYL0b/KrVz3Qzi7x/AzYt8R1RhWY061 /IfcFGBqmLf8+c04JfMRw8YRraZ8m0D4vwF3V8KAEf3Em05G9DQn1InGsgpYTN5Ne6Cd C7r5UpbM7abjwPO08VAmN5PKIIf9ssXRroPXT49hk/WCsm18hnJAag+Yh3zz7WaxgA5V xYqA== X-Gm-Message-State: AOJu0YwZyac5pRmWO5YcVWaNdCT3RARbPzxr0Gg/6Nd/LwLyQlY5hEm2 s1Douww1PDhbVv/LUQ8OeSru5NQqA9ThxrCIWEJBOkcEhPCIi/KvOl9R1e+5 X-Google-Smtp-Source: AGHT+IHQVDolaz+ffC6XiNrT4BeaNr88NXOtb3duEA/A+VZYN26KAYDkaRoAxW8iptbY8Bz1wmyxow== X-Received: by 2002:adf:ef90:0:b0:33a:ded0:c309 with SMTP id d16-20020adfef90000000b0033aded0c309mr4390143wro.13.1706534884624; Mon, 29 Jan 2024 05:28:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n4-20020a5d4c44000000b0033aeda49732sm2734130wrt.33.2024.01.29.05.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:28:04 -0800 (PST) Message-ID: <426374ff9b3820512f73ef094f9533e6a1ea5cad.1706534882.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Jan 2024 13:27:58 +0000 Subject: [PATCH v2 2/5] completion: complete 'submodule.*' config variables Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In the Bash completion script, function __git_complete_config_variable_name completes config variables and has special logic to deal with config variables involving user-defined names, like branch..* and remote..*. This special logic is missing for submodule-related config variables. Add the appropriate branches to the case statement, making use of the in-tree '.gitmodules' to list relevant submodules. Signed-off-by: Philippe Blain --- contrib/completion/git-completion.bash | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 159a4fd8add..8af9bc3f4e1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2803,6 +2803,19 @@ __git_complete_config_variable_name () __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }" return ;; + submodule.*.*) + local pfx="${cur_%.*}." + cur_="${cur_##*.}" + __gitcomp "url update branch fetchRecurseSubmodules ignore active" "$pfx" "$cur_" "$sfx" + return + ;; + submodule.*) + local pfx="${cur_%.*}." + cur_="${cur_#*.}" + __gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "." + __gitcomp_nl_append $'alternateErrorStrategy\nfetchJobs\nactive\nalternateLocation\nrecurse\npropagateBranches' "$pfx" "$cur_" "${sfx:- }" + return + ;; url.*.*) local pfx="${cur_%.*}." cur_="${cur_##*.}" From patchwork Mon Jan 29 13:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13535655 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D953964CFB for ; Mon, 29 Jan 2024 13:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534890; cv=none; b=A5LyDIgVXtt/WNsXyCDOlSc3UcURZaTOdbm0E8f8G/E4sxDal67xvhZhFhXvikhWvxejUc2UlAAiYZgNhqqp14p4z6AeqW+mzF7fYcRN+91BcsKXofHr6nt5nlrj6KTqUHmqwBu5KkrU6M+RajgXKCZwL68/INo/CdrgWpNNt8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534890; c=relaxed/simple; bh=TwyeDdsOxKgszuWZL01yj8xfJwSkG3yb6d4+Z65WPgI=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=rpTzyX0iNFwaXRBdtopxLNEGS3h4vwwJ7hwrb6HSsolUuDk81MEFtzdC5hFIwjx3Pr0PgEZBerl2JztN26Crtfgd5U08RvqwF9T5qzsEH5Mj9xg/FIlVnbeZaBNsoJpQKEVEVRVskaDsjIo5YaI8w9cfpDAUEeHuhvXj0Ybb7Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iax+fXk7; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iax+fXk7" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40ef64d8955so8987975e9.3 for ; Mon, 29 Jan 2024 05:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706534887; x=1707139687; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=5byi4K+FqXpCK1PjPxawgqP73bKSooFEtJ77nWOXb4w=; b=iax+fXk7Qb+JN0Fu6sNF08ChAHASK5y/6gRlz0p/FCLerT/IoqMnqCbaYswWntQjv2 DS3w82KQbhNea/RVm8DV6k7Y0wo96iqX4L5flO4dGIuf8IBEgxy7LBbtolKKlQQlCLSd qZii9c27cDs03cah7jmtY3JEJeVKAo37HPu1F/3itHMFVjUEMS1tBxY1Cp9vpW2CtgYV Xpm+9Mr0x/127xrqEqBQaLd29GHniUxTTv5TRRkXKVwhjmQ0cQtYmEIYuLNP6/OoJY73 MaWzZ4IctRcnOJUSB6rut6n6oOXjPny/uXRUhtxyc/9VN/bVbIe4/L0i16Q/K7ArSUhn Q+Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706534887; x=1707139687; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5byi4K+FqXpCK1PjPxawgqP73bKSooFEtJ77nWOXb4w=; b=LTtYSrkapXHSRQh4NOh7JUhXrGS9pbeweYAzm3sTAJj9NTX7dSO3r2cme82gcZ/9DD I+v1DcZkQdAkqHNsnXANWNgewCav4lUiwcPXUe+VBQYzKvVCZvSgg2UZsgkPTfSwyv6p RrS500CWeU1Tf4dGpRCOsqW1GqzZi/QpsXgNDLAla/V8naV+5TjAFwqxwZ4zvh6QPLhG YSIVxiZqeIt3hFmI6mwOfcctBxWbEYhD2STL8tXLUM/14Yp6lHXiPfPYI+U0rW6oMKtc eXyl2Lbv8hgyb+7qceYxvu8IwGsYvi+RxlYFi7WPWO9Zui3m23c+SjLuhraPVrfJSZ+q WG2Q== X-Gm-Message-State: AOJu0YzOql+LqYF3fK4qTEB5WsMtdDbda5ejBWcnW6jVrkq+Tzqkm3vA 9Q6Tj94d96LgBCVjwvJy/mZSeoQcb3R45gGqhb1q4G57vePDRkmvg7rvKPZU X-Google-Smtp-Source: AGHT+IFQrRBDfKt/xxBvnSSYKOufFqvzmfOs61535oxoDnZP/m1242Khg+2jo3IztVBGT5ZiOLuIiQ== X-Received: by 2002:a5d:4312:0:b0:337:c91d:e80b with SMTP id h18-20020a5d4312000000b00337c91de80bmr4244056wrq.13.1706534886445; Mon, 29 Jan 2024 05:28:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h5-20020adfe985000000b00337d67a85c1sm8078525wrm.62.2024.01.29.05.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:28:04 -0800 (PST) Message-ID: <838aabf2858b73361be8e8579bc80826e1cfd4c3.1706534882.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Jan 2024 13:27:59 +0000 Subject: [PATCH v2 3/5] completion: add and use __git_compute_first_level_config_vars_for_section Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain The function __git_complete_config_variable_name in the Bash completion script hardcodes several config variable names. These variables are those in config section where user-defined names can appear, such as "branch.". These sections are treated first by the case statement, and the two last "catch all" cases are used for other sections, making use of the __git_compute_config_vars and __git_compute_config_sections function, which omit listing any variables containing wildcards or placeholders. Having hardcoded config variables introduces the risk of the completion code becoming out of sync with the actual config variables accepted by Git. To avoid these hardcoded config variables, introduce a new function, __git_compute_first_level_config_vars_for_section, making use of the existing __git_config_vars variable. This function takes as argument a config section name and computes the matching "first level" config variables for that section, i.e. those _not_ containing any placeholder, like 'branch.autoSetupMerge, 'remote.pushDefault', etc. Use this function and the variables it defines in the 'branch.*', 'remote.*' and 'submodule.*' switches of the case statement instead of hardcoding the corresponding config variables. Note that we use indirect expansion instead of associative arrays because those are not supported in Bash 3, on which macOS is stuck for licensing reasons. Add a test to make sure the new function works correctly by verfying it lists all 'submodule' config variables. This has the downside that this test must be updated when new 'submodule' configuration are added, but this should be a small burden since it happens infrequently. Signed-off-by: Philippe Blain --- contrib/completion/git-completion.bash | 24 +++++++++++++++++++++--- t/t9902-completion.sh | 11 +++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 8af9bc3f4e1..2934ceb7637 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2596,6 +2596,15 @@ __git_compute_config_vars () __git_config_vars="$(git help --config-for-completion)" } +__git_compute_first_level_config_vars_for_section () +{ + section="$1" + __git_compute_config_vars + local this_section="__git_first_level_config_vars_for_section_${section}" + test -n "${!this_section}" || + printf -v "__git_first_level_config_vars_for_section_${section}" %s "$(echo "$__git_config_vars" | grep -E "^${section}\.[a-z]" | awk -F. '{print $2}')" +} + __git_config_sections= __git_compute_config_sections () { @@ -2749,8 +2758,11 @@ __git_complete_config_variable_name () branch.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" + local section="${pfx%.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }" + __git_compute_first_level_config_vars_for_section "${section}" + local this_section="__git_first_level_config_vars_for_section_${section}" + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; guitool.*.*) @@ -2799,8 +2811,11 @@ __git_complete_config_variable_name () remote.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" + local section="${pfx%.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }" + __git_compute_first_level_config_vars_for_section "${section}" + local this_section="__git_first_level_config_vars_for_section_${section}" + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; submodule.*.*) @@ -2812,8 +2827,11 @@ __git_complete_config_variable_name () submodule.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" + local section="${pfx%.}" __gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "." - __gitcomp_nl_append $'alternateErrorStrategy\nfetchJobs\nactive\nalternateLocation\nrecurse\npropagateBranches' "$pfx" "$cur_" "${sfx:- }" + __git_compute_first_level_config_vars_for_section "${section}" + local this_section="__git_first_level_config_vars_for_section_${section}" + __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; url.*.*) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 35eb534fdda..f28d8f531b7 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2583,6 +2583,17 @@ test_expect_success 'git config - variable name include' ' EOF ' +test_expect_success 'git config - variable name - __git_compute_first_level_config_vars_for_section' ' + test_completion "git config submodule." <<-\EOF + submodule.active Z + submodule.alternateErrorStrategy Z + submodule.alternateLocation Z + submodule.fetchJobs Z + submodule.propagateBranches Z + submodule.recurse Z + EOF +' + test_expect_success 'git config - value' ' test_completion "git config color.pager " <<-\EOF false Z From patchwork Mon Jan 29 13:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13535656 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58D52657A3 for ; Mon, 29 Jan 2024 13:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534892; cv=none; b=HXQAhfAsRPFlroQBfp8WeQT8BCRkNTpMD8Kgmcm0bgGFWHsfIw3gboES/sBF0Z4jSCMpLAy3/c3qq/CKSuhPsXl54m+nOQ8RNLM+t+eH6eLcb83eITO1EGPkRsMi/qr9bOA1NprUxk1RlY2Xw/MWqc9E9Dql6C3N+gOzrHke2eE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534892; c=relaxed/simple; bh=2vtrJHbRnX+npVfLN922a7kuIY3hHTq3L1bsZuVpGTg=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=hVDrd09fNt1fpJF0409mPNwNQEuw1F0NBGZvUYOS5+a5FbH7xKRilV8zR9IrnBGJ3L2D3thJtD1hGTcRn2Sbx6WeZL9vtngj9gP9x1/mLv9xA57A3do3956mq39KhwMhzRkIVkzPDtTWY7/Xgqx5ihIIjQTNbWJSAbUFb5JwPU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EfKS/Uiu; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EfKS/Uiu" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d04c0b1cacso10602221fa.0 for ; Mon, 29 Jan 2024 05:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706534888; x=1707139688; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=5dEGWprWWUyitE72gJhxPCNtNyO5AFJdA4Ck7/jeXsY=; b=EfKS/UiuYuyBwaeCfwxfN9R/E0VH8CXvjFd5eKReVY5KLSvdiGhaNJvIn7X6cJFEra UVfvUaIUIS3MMAUBzyspSuAELHGaLEm/CiV+0jgNwG9fybmOPl+NT5zlt1rBUPjXgJYh nX6BD4RyVUYaG/TJyNHxSU7mh8GI3t2R7P7aJaa7j8fmPIoy6LfgxHBDlZX9SgNas4MI G2jWqjAL3mT3EaM7NWcDMshFscp/fo4Ij3heUs/7jpx1O0tvifOKGA2Ptd8kTPZANdzh 3ch3dlM0iF79U3NbBTNCBKTq9TIcJe+tEMv22ylP0DTV1czBExt4x8xhDLdF6IZC4942 UpCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706534888; x=1707139688; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5dEGWprWWUyitE72gJhxPCNtNyO5AFJdA4Ck7/jeXsY=; b=Ipkkv7RNyaDDIhGc2mRRQhN63Y6KchzIQ7VtVeNHtzfE1S6wjTme3JgF/pqIK0PFz8 v7KKa5J/S303LHDPMfYHq54Oi/V6RGkYGeLKlV6WDofHS8mlsu1/IwUdBK6z8EnL/1Bs w3Q+Z+6AMWPhRT2/h6/R+YXyPoMUNkIX3VQHedkqv8WtCTD6sFvWSZMWj/0q+7zJ70AP gsrESl40YM4MpPMeRz2TpKISQeQy3fXoByk57DBQ93Tl75/Juo1KIC4Vcn4uBaORrH8z ET7D/UM5lsT8xbkxA4SssZsifo0cRCCpLQR/FFTnqKtmMm8p9+ZGskCse8SWwWnO0P9l zYYg== X-Gm-Message-State: AOJu0YwS5FPl/vBba6QvRbhtqvlRIh9SzlDFnGp/1DprLmWFH5OnDnKt XwJmLslGNoElT50lxrWuYOfo3JxjOgzRIIp8UTCvrQpy0ia6DkUfYTLVervz X-Google-Smtp-Source: AGHT+IE0uWEnInhIqkGE/yk/nTbNuofcHxqcqYboVtWbp/R8fSkiJ27mCXOl7PFJWQirOwlWNRgwPw== X-Received: by 2002:a2e:8896:0:b0:2cf:2fc9:9a08 with SMTP id k22-20020a2e8896000000b002cf2fc99a08mr3727969lji.24.1706534887493; Mon, 29 Jan 2024 05:28:07 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bp19-20020a5d5a93000000b003394495566dsm8219605wrb.22.2024.01.29.05.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:28:07 -0800 (PST) Message-ID: In-Reply-To: References: Date: Mon, 29 Jan 2024 13:28:00 +0000 Subject: [PATCH v2 4/5] builtin/help: add --config-all-for-completion Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain There is currently no machine-friendly way to show _all_ configuration variables from the command line. 'git help --config' does show them all, but it also sets up the pager. 'git help --config-for-completion' omits some variables (those containing wildcards, for example) and 'git help --config-section-for-completion' shows only top-level section names. In a following commit we will want to have access to a list of all configuration variables from the Bash completion script. As such, add a new mode for the command, HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, triggered by the new option '--config-all-for-completion'. In this mode, show all variables, just as HELP_ACTION_CONFIG, but do not set up the pager. Signed-off-by: Philippe Blain --- builtin/help.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builtin/help.c b/builtin/help.c index dc1fbe2b986..dacaeb10bf4 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -50,6 +50,7 @@ static enum help_action { HELP_ACTION_DEVELOPER_INTERFACES, HELP_ACTION_CONFIG_FOR_COMPLETION, HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, + HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, } cmd_mode; static const char *html_path; @@ -86,6 +87,8 @@ static struct option builtin_help_options[] = { HELP_ACTION_CONFIG_FOR_COMPLETION, PARSE_OPT_HIDDEN), OPT_CMDMODE_F(0, "config-sections-for-completion", &cmd_mode, "", HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, PARSE_OPT_HIDDEN), + OPT_CMDMODE_F(0, "config-all-for-completion", &cmd_mode, "", + HELP_ACTION_CONFIG_ALL_FOR_COMPLETION, PARSE_OPT_HIDDEN), OPT_END(), }; @@ -670,6 +673,10 @@ int cmd_help(int argc, const char **argv, const char *prefix) opt_mode_usage(argc, "--config-for-completion", help_format); list_config_help(SHOW_CONFIG_VARS); return 0; + case HELP_ACTION_CONFIG_ALL_FOR_COMPLETION: + opt_mode_usage(argc, "--config-all-for-completion", help_format); + list_config_help(SHOW_CONFIG_HUMAN); + return 0; case HELP_ACTION_USER_INTERFACES: opt_mode_usage(argc, "--user-interfaces", help_format); list_user_interfaces_help(); From patchwork Mon Jan 29 13:28:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13535657 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F1CE64CC7 for ; Mon, 29 Jan 2024 13:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534912; cv=none; b=uu6ADSx/aW2Lt4k6F/0xGxwIc8Zj4HeIsl638kx5bcYSrVlzgQUZ2qLdbWp7WQaP/R+VL9H1uvEZAi6cRU+OI/6jMAmrf3fdUA+DgiX31KvKYgFx6um8iRgBQIR6L0X37KcwxCUTHa55RGsh4LEE5Th6hwCj2TudLxcOIfjdpn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534912; c=relaxed/simple; bh=qs2JfaacomBYZSJbBIC0nQLE5azEC+6LeTMFhMZ7orA=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=aCJ3skk6doUq4QjUNNXiNUGsXRcew0SjYgzYzbnYofF12mDpC4sbb74huwu2H7WTmcq3dI5+9FW4Tv3TXCe47yDbFhRxwYJyXUhMTE4rKT8F4Tr982Wkzrq0J5DViue94Ah7MQ8Mw4ANW3rvSh/5tTXYc35o0bQddouZCQuM+qs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hkPk5A3j; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hkPk5A3j" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3392b045e0aso2263878f8f.2 for ; Mon, 29 Jan 2024 05:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706534908; x=1707139708; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=pI8Axo9a8gsIKHPMBImKiuAar+merz8URnLTsQpVhl4=; b=hkPk5A3jUDLmdCtH62FyuQnzHBuq9MTbg3D/ArLKqBHPcnBir1LkmjRvorDKtM7RLu tmSyIodTEgk/Qsdu1Cf22pwKGcec8/y9kK1R3pSHay88ApRs7Ttkp1ke7bHUSW188XJD 3698U9d/N9FjphTUtyhWi413fW4uHJFJcK5qdtt41iKKrbdMoLCFYA86vE2V446DjT4a v+sqg4deEM43IqyBdNF25qbayvzn7spqGxkpfG2nEr8Yjzr4/+jk9rHEXnnWLXOMQI6c 49eZ/P4l3yZZq+1gD1QKboKZLugaytBp8VXxpcf1rIzgcFexnn4UcOjnlRrchG4ptyg3 LRcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706534908; x=1707139708; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pI8Axo9a8gsIKHPMBImKiuAar+merz8URnLTsQpVhl4=; b=SlmagE3rVh4pM9ffcCNguHRPgU/eKrUo+7dDPowlGWW5bAexvnOvrUjNyoisLmtIIi K92l5ebCW4a6G7a9zn+rysdhFVdFyILwrKRbn0WdzQj1ZBxVLbf3F7f8LElTih9TiJjC XfJvnv97BoA/UMLS/r/aqo++WHQHqAx3tN6SCfv6Q8iRJnho+swbSbImi/osCMTU+N0F MLUQNfx2WOabINJlCEZRWalSzYDPH2BAqxPU4gD1KhrBwbqioGx9yOjSymm+L6F183Fq NN2f6jDOj/Z+rNC6UojaywKJ0wTQeGBvh+ClTHIYBCoy26TwBORqY/35yK3a0hZrDR48 RHyQ== X-Gm-Message-State: AOJu0Yx7JwpElGvkTqtJ+DMi46EorXMkdzyED4bLeplx3G64/2PvNO0w Tsk5wQJfYwZEsiwKsooOb2QwJ45oL4/rZcVZ8G5APG6pyvg9CA3/rnSORybJ X-Google-Smtp-Source: AGHT+IGbYljSnfoeHcyxJqyM0Cc9LOOc11YQvW7mgJMAwPnJEQkUP6Jn2YDxab6mobu3Us57r8bNdw== X-Received: by 2002:ac2:4bc9:0:b0:510:12e5:c6a8 with SMTP id o9-20020ac24bc9000000b0051012e5c6a8mr5096471lfq.47.1706534888121; Mon, 29 Jan 2024 05:28:08 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v12-20020a05600c444c00b0040ee7175eb1sm8850880wmn.9.2024.01.29.05.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:28:07 -0800 (PST) Message-ID: In-Reply-To: References: Date: Mon, 29 Jan 2024 13:28:01 +0000 Subject: [PATCH v2 5/5] completion: add an use __git_compute_second_level_config_vars_for_section Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In a previous commit we removed some hardcoded config variable names from function __git_complete_config_variable_name in the completion script by introducing a new function, __git_compute_first_level_config_vars_for_section. The remaining hardcoded config variables are "second level" configuration variables, meaning 'branch..upstream', 'remote..url', etc. where is a user-defined name. Making use of the new --config-all-for-completion flag to 'git help' introduced in the previous commit, add a new function, __git_compute_second_level_config_vars_for_section. This function takes as argument a config section name and computes the corresponding second-level config variables, i.e. those that contain a '<' which indicates the start of a placeholder. Note that as in __git_compute_first_level_config_vars_for_section added previsouly, we use indirect expansion instead of associative arrays to stay compatible with Bash 3 on which macOS is stuck for licensing reasons. Use this new function and the variables it defines in __git_complete_config_variable_name to remove hardcoded config variables, and add a test to verify the new function. Use a single 'case' for all sections with second-level variables names, since the code for each of them is now exactly the same. Signed-off-by: Philippe Blain --- contrib/completion/git-completion.bash | 71 ++++++++------------------ t/t9902-completion.sh | 10 ++++ 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2934ceb7637..0e8fd63bfdb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2596,6 +2596,13 @@ __git_compute_config_vars () __git_config_vars="$(git help --config-for-completion)" } +__git_config_vars_all= +__git_compute_config_vars_all () +{ + test -n "$__git_config_vars_all" || + __git_config_vars_all="$(git help --config-all-for-completion)" +} + __git_compute_first_level_config_vars_for_section () { section="$1" @@ -2605,6 +2612,15 @@ __git_compute_first_level_config_vars_for_section () printf -v "__git_first_level_config_vars_for_section_${section}" %s "$(echo "$__git_config_vars" | grep -E "^${section}\.[a-z]" | awk -F. '{print $2}')" } +__git_compute_second_level_config_vars_for_section () +{ + section="$1" + __git_compute_config_vars_all + local this_section="__git_second_level_config_vars_for_section_${section}" + test -n "${!this_section}" || + printf -v "__git_second_level_config_vars_for_section_${section}" %s "$(echo "$__git_config_vars_all" | grep -E "^${section}\.<" | awk -F. '{print $3}')" +} + __git_config_sections= __git_compute_config_sections () { @@ -2749,10 +2765,13 @@ __git_complete_config_variable_name () done case "$cur_" in - branch.*.*) + branch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*) local pfx="${cur_%.*}." cur_="${cur_##*.}" - __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx" + local section="${pfx%.*.}" + __git_compute_second_level_config_vars_for_section "${section}" + local this_section="__git_second_level_config_vars_for_section_${section}" + __gitcomp "${!this_section}" "$pfx" "$cur_" "$sfx" return ;; branch.*) @@ -2765,33 +2784,6 @@ __git_complete_config_variable_name () __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; - guitool.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp " - argPrompt cmd confirm needsFile noConsole noRescan - prompt revPrompt revUnmerged title - " "$pfx" "$cur_" "$sfx" - return - ;; - difftool.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp "cmd path" "$pfx" "$cur_" "$sfx" - return - ;; - man.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp "cmd path" "$pfx" "$cur_" "$sfx" - return - ;; - mergetool.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx" - return - ;; pager.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" @@ -2799,15 +2791,6 @@ __git_complete_config_variable_name () __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }" return ;; - remote.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp " - url proxy fetch push mirror skipDefaultUpdate - receivepack uploadpack tagOpt pushurl - " "$pfx" "$cur_" "$sfx" - return - ;; remote.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" @@ -2818,12 +2801,6 @@ __git_complete_config_variable_name () __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; - submodule.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp "url update branch fetchRecurseSubmodules ignore active" "$pfx" "$cur_" "$sfx" - return - ;; submodule.*) local pfx="${cur_%.*}." cur_="${cur_#*.}" @@ -2834,12 +2811,6 @@ __git_complete_config_variable_name () __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }" return ;; - url.*.*) - local pfx="${cur_%.*}." - cur_="${cur_##*.}" - __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx" - return - ;; *.*) __git_compute_config_vars __gitcomp "$__git_config_vars" "" "$cur_" "$sfx" diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index f28d8f531b7..24ff786b273 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2593,6 +2593,16 @@ test_expect_success 'git config - variable name - __git_compute_first_level_conf submodule.recurse Z EOF ' +test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' ' + test_completion "git config branch.main." <<-\EOF + branch.main.description Z + branch.main.remote Z + branch.main.pushRemote Z + branch.main.merge Z + branch.main.mergeOptions Z + branch.main.rebase Z + EOF +' test_expect_success 'git config - value' ' test_completion "git config color.pager " <<-\EOF