From patchwork Sun Jan 28 20:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13534624 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 0C7D83219F for ; Sun, 28 Jan 2024 20:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472179; cv=none; b=ULTKTt2vl0+qTy90FS8DNJJTNTivYrwKsdqDnbZdH4LJ9DQh4yVTwFMnUQorS3bFlsjtuvhI4ND6KHydfaYAEPaZbuH+v30dgNvCpe1G+BoAJu1YHz9TLCPDn/e4KWpezeV9tW1AYlQ8BjFGSDBxOBG2uj5S0Y4lPyQ/nRonDtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472179; c=relaxed/simple; bh=lvMxwpu5SITz45OThYK9Sw30XiLRRcYvW3f6jY6Cpqc=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=FFDPUq7NMdYpHTMuC6TGbJ0RGpKjLyyexnOopLa4Qhn1X0dytR4JbLbB5qztUnTqka4+x5xfN9sA4Yya2TWL76cArQUWqQ0swoh3gAKYMuFgHVGCJ4QFTDbQlIvQPkaLMzIuKfGGIJsMc8m5xyfT+klAoD1cxzKNJsT1qOjLNzA= 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=f68UeDkr; arc=none smtp.client-ip=209.85.128.41 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="f68UeDkr" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-40e80046264so33295925e9.0 for ; Sun, 28 Jan 2024 12:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706472175; x=1707076975; 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=f68UeDkrmbFMvznjVrRznAeyZB3SRhLBHcSf0956U44S1Fx9gt8KaPnEY90wnXUaKR 5o8MaVy+AihkRk4qxXXrrCARu/cNgOaZ33ZlJRVgsGuG9Je1QB7Ru0IW3JV12WSHYD5c rlW9dZyogt5vq6AzcHp/1IsPOK0NNj0asvHmwVpQtbPMf9aMOHnY1o9TylxRbyxVk0TL dxC9oM+6lDsGsb+s31taFgCyNTg54SfhhTknVIg4BIQkBnpyS7TDkLfG0NwnJCK+x5U9 dVCBgXVnlzni1cQZAcJn2CrOAhdz4uUoCXAeNBDVuNrrBIy9g9fDT0Mb/lIgIOKmyiFL 247g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706472175; x=1707076975; 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=u4cs0THNqQj1CuBI6XnpSK7yTGBufNmOjqSHZ28zhqcQbHHeZ1AVtyeEIDlVuW7wE0 CZEmaLH+N+iOnRaWU0kbNrlZGCcjT568pvDeXuN6COw8Mwzm5QjL3iv7zXMlXziub6hg vEBMKdMK/dQo3VKz01byUr7HzmMWBzGyK+lgv7afm+PnT/XwmfWxsAYIS8XeHe4xr1wV SieoSAvwrSG1j6YspAQCp4b1gK+7n5buMUEi+imOUQcezNEi73yBQCdc+louBE3oGZhZ zSmEY3tHZ03oluWCPI7rg1r/m36C10Q44PKJRK/SONGihF177ySDijvY4rfjkwBmFQul ND8g== X-Gm-Message-State: AOJu0YyFoqSOK4/N2HX8g2gYgNN+jriBjY6emlV45VOWk4Ikp/lyd+pW Ow24UT4wnVOh8EFGewpsEmEtQx7ybLMBlZaBEWUpse2hOrKxE1pPdvnXDTv3 X-Google-Smtp-Source: AGHT+IEe4KOW6t/0Yx2+wBQsqHj03N3YRnMn20KR4sbWIEOVqpDQMsu79emGcyf23NmYLtpoju1jrA== X-Received: by 2002:a05:600c:46d3:b0:40e:a255:8f53 with SMTP id q19-20020a05600c46d300b0040ea2558f53mr3604637wmo.13.1706472175275; Sun, 28 Jan 2024 12:02:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id fc20-20020a05600c525400b0040ed1e5d5f3sm11133620wmb.41.2024.01.28.12.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:02:55 -0800 (PST) Message-ID: <837d92a6c277015fc8633ca84557124465390548.1706472173.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Jan 2024 20:02:49 +0000 Subject: [PATCH 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 Sun Jan 28 20:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13534625 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 5E68C33CF1 for ; Sun, 28 Jan 2024 20:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472181; cv=none; b=pJhcINyyobnalkXg5xqMXjLK6cjGWakxHeSI4d6keSnLNqNAz/AsQgEyq5A0RlEZDQTOaswHKbpS1bIFXXXXe5q1rXKOD5ZoHRlSroZlDPnsnEuOxGv2zzqFWBB8ZRODzgHHuHO+Wox5X38hth2mbpVpeLZpHIQAU3OU35xTM/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472181; c=relaxed/simple; bh=JvKtPDHJ48vz82xUkRsv3Nv89lW37Os5UFzaCwSGDYk=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=hK7vqPB8+Kh7BeFQWtLYwEQbgkNOXSTwCZPvY9E4v/0tbT1FdC2XOykXg5sI0wXdUkskB/l1v43YCzkeU8o7DZDyuKN6fRZ4N0uGgvXJPPxbiv0g3pSpodyTgJBdFbgVzfCrfWVb1bS33HnkzqeU0PESNAnt9SeKUgsOvliU8pI= 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=VXj3yFGc; arc=none smtp.client-ip=209.85.128.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="VXj3yFGc" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40ef6da20feso1215115e9.0 for ; Sun, 28 Jan 2024 12:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706472177; x=1707076977; 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=P46ysJSHKd19WYeeO6NfozEmyz/5Wuqmqh4NooshRe8=; b=VXj3yFGchUT5x/Y3lHT0bF8VGQnEl5zGP74Cjc+Un+iLFzvvxW/bHkaNQvZU3ofTab LsXH2I6uYeMP9blJ8alElmqI6Qa6V8uZHKpiQRcqbnw/Wzp1BJkjrtoIHN9yf+1REWwF JMYsA1ryFbG3SmSwijrwdkkw6B9j/8YbMHWjUVJTtGnKTWoqMeL/VZguympjPE8O8rhQ STQIQautfYGxV8grH5k+nuKraKITKpn1w55stUiZm+M3KMYjNUq8HQj9DjrXzofZzZVT +jSSQJbKZv3tLIiHsFWOvvVVaUnq+cNY1IZBcsASdFoOZqXPbblc2G1WP4bvyNQKusPT kMfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706472177; x=1707076977; 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=P46ysJSHKd19WYeeO6NfozEmyz/5Wuqmqh4NooshRe8=; b=uXlIMkNcWg0zB5gq1axXm9DbB1X/pYT/ZyeXh/I3YZ9vZ1LJR3qcuakIFCMzf9Rm3f L0tPBPqEQ1Lk53g5xD9tQ8/wEkjgFM18bYTHAlgl1v4G5GNxFHPHyYbC/T06Tu56EHeD h0qFw0owDSjA7JLWp+rCWvw/QYExEbV5xyuUBsKnswKhS3Wfzb4jFUOKV3PQesI0GtkZ xjV99thW5cFk74ZvqWLOzcjx/qUyVXCKtsuM1K7GymSGjnlJke+6VuQYZBZLvyIYTQ7v v4zHEftPp7l7d3RCC4Rbp2ijyPuph5cnGvyVwJtM9C74V/QTPHBEaqFHX+iC5BCWjuEi 8GWQ== X-Gm-Message-State: AOJu0YwTmBxZ9bAxmnN4hx78kd8W1Q8CVIzxJW1I9rR0vMFnje4/RbHp fcn/sfyzZ5iAFKNBHErORPp4ymOEFJUh7okekM8oPu7F193d4HVEeo7zadOY X-Google-Smtp-Source: AGHT+IF+0ssZgnV2fg6ti8/MiSqmiVpxdyWjo6mO36cPdUDSldjwV3GRvKyu7HhhfV1Emfx2niHQ5Q== X-Received: by 2002:a05:600c:4743:b0:40e:bf71:f6db with SMTP id w3-20020a05600c474300b0040ebf71f6dbmr2838612wmo.17.1706472176844; Sun, 28 Jan 2024 12:02:56 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d7-20020a05600c34c700b0040ef67f1f52sm1396404wmq.7.2024.01.28.12.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:02:55 -0800 (PST) Message-ID: <2dd3085f8d80fa1f5209cffde60b4ab98766baf9.1706472173.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Jan 2024 20:02:50 +0000 Subject: [PATCH 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 Sun Jan 28 20:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13534626 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 42A3C3C062 for ; Sun, 28 Jan 2024 20:02:59 +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=1706472182; cv=none; b=Fwv2pwDECyHkuKBQcteeG7mp5nOrLiOMW2YKdhoajdvNuQ1/CIheGA1V3o1NP79XVaKPKTufSBux/4MIuDq+u3azHfpz+E4mTZw7fIw7Lu2A1OYhviH4iJSzJ0qXKD+EQxTMn4B4pcSg9aYvIzqPkJo7ZmItrx85sfflN3rLYak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472182; c=relaxed/simple; bh=TwyeDdsOxKgszuWZL01yj8xfJwSkG3yb6d4+Z65WPgI=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=UzZ3pS2/bw/PNwE+J1G3kR7OFOxEzuosq+g95oZUomVxxMWTR2dWUmp77Csqw29RmdbRatcGPZOHwJnpk3jCX9t15iKE6cWkasuj2nbwpb6h+14IKcsFgN8BfxC2MMyJEQqmq2uE7MhvrNYiZY6vCkWRvOKxfLyHA0HSLmULwZY= 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=j1aC1xc2; 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="j1aC1xc2" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-33934567777so1960047f8f.1 for ; Sun, 28 Jan 2024 12:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706472178; x=1707076978; 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=j1aC1xc28+wfsVbC9svBNt0iRmkvC/gj8EUl8/iE32dCSKonPf9otv2vL5DMs3ZMnh p8KzOvgkQwnLQZhHhuPOepfEvYilSdEsW4rgvPNseSRijONcxApQHC6ce2Dp/8q9Z/KX VpeBMuzARxBcEgPcKqWi4bQIhjsBdhbPgqRCo3PGvotA4c14dlGg8OdRC7JKeFGtfk0y Zn9A+qGfpsBLJYN+yoxYnC5qXYI1PMgwadXV7cE3xzjLYtuoPpTUWwJpI7NsfD+vNPwM NtOQsw6s3YttfbzIg/+2J81bsWsu6DsPvr1mBIg2u46UpsfyUtu56xHTpfPxDArfT50y hhoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706472178; x=1707076978; 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=Qx6tozmkD7ADSml/dwpe7RVr2SxjtWQIQ5Q0MgUjYZZzmSCPYhWRVHk5SzcaK3cgQ1 OFQasNomwHjApdQqojl5nfPlC0rKSf+7743ODoUsIiC+zzxLbzuI/cFGxFn1jXlMYPBg SR/hLg6wVw9LyAdFFwEO94d1FU92wVlq3MHtCBV/fFE8WDXINB4+COgilQ5Ebo5O+FdZ IpJlrdxkvQTlkMOpJ+5vcZc+Yuzt5qyvy+bV9vfE/dcHJECfuBYlmTmTnH5B5UobZEAf X4ld+gIjA+PRK2jY37R5q8CS+lhDIR621WmBCofx9En3XPsY7dWVIARljem6NxN4GLpB gP2g== X-Gm-Message-State: AOJu0YyPD8DWIy1lwaM+sQistGIEFSfFtXcEsrSj5KLodAg+8qvyNffk eup3OrZ4VKaCU+ExCyWn2SHw7A6sjBM58gckty4sZFCzxYSDANUz9bTrJcD/ X-Google-Smtp-Source: AGHT+IF1FTwRQivwCIW2eT93v3WuuBhT9O4KF+0QlGYCXGDZR5wLsTrpZQwI0NIPP4QX0vkwk0djzA== X-Received: by 2002:a5d:4312:0:b0:337:c91d:e80b with SMTP id h18-20020a5d4312000000b00337c91de80bmr2941132wrq.13.1706472178111; Sun, 28 Jan 2024 12:02:58 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y11-20020adffa4b000000b0033aee139e26sm583889wrr.63.2024.01.28.12.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:02:57 -0800 (PST) Message-ID: In-Reply-To: References: Date: Sun, 28 Jan 2024 20:02:51 +0000 Subject: [PATCH 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 Sun Jan 28 20:02:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13534627 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 741AF3C46B for ; Sun, 28 Jan 2024 20:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472183; cv=none; b=Lji6gCq6SbfXzMzjRW1aDcswlogr0ueDkBp3hQv0JZYQhgx/6qFdHausuh0J8zBTQhAG0hRUUFeOG/LyNvHrFEPTofpV+BJ9kzaQUJY0jLq1hi5Ds9HdR44tPDr8myZkvpq/65E+8jVgPACnpPalY2sNRNPp2DtkF2PSq1tP7j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472183; c=relaxed/simple; bh=2vtrJHbRnX+npVfLN922a7kuIY3hHTq3L1bsZuVpGTg=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=fbsNddHK3ibcFRyPFx/fk6kzgCkse3+I5o/OaQTuzWj+qSLLiFgIdjkcii7E5ggwZOyR31u/2tvmNQqpYD8DpeCEqITKkRGP7NTbQX4pqWVD8aenBgBLkYt9KhjY6spU8vpFzjSM7LQBz2ptG+6cFigigJGjaz0DRBTwRTpjjPs= 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=Hgk63iTn; arc=none smtp.client-ip=209.85.128.53 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="Hgk63iTn" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40ef3f351d2so2446645e9.1 for ; Sun, 28 Jan 2024 12:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706472179; x=1707076979; 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=Hgk63iTnaN4QmX7QNvt9Al0+oJsDBjzL/Sx1rKKxwod5gWAxB2wpk539Ivy1BjSLGv qyc6/ISumBTfuYTDR99rfDCz/FdQ+8ey8HBiGTKpKxHWWVW+h5BAdSD2O/ZRWy4LgcKr O2WC+0PjW0QCIHuLgF+tGzULmMaD3KbDAIjyyeuNQLX54C8zOcgr35dzWkDLiTa2uOnt Hj2L4bW6qSNUO537fDCh3Be6zmIe4aHviioGhmOKiY7EeGbN/cOJdCdhH+KW6sSnPSoD L/wxpypxM+imq68OU99v7VKWP+V8//sSVba4ZESvuU9KruW1Kk5PLfzTuXSf2MWytZY1 auyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706472179; x=1707076979; 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=LEVy9MhX8RtrjNMwPCa8r+8oYq6gt9UuqpP/12W5fnKMN+DemiL0eeb1LI9FUwQff8 AFIdvZ7fizRMkDo94m+BpFXc+S7y3tB+TZJSOWrc+isx4hsk43ld4FwmZ1dKJ0ehY/2v C0ageY4suHMXh17830AmQLAUu97DZSdkpRD7pOXIDjcY2XSs3Ex8veqW1s+B7r+yvcRD VE3rDc7BEZwegecGunxzLiQNLj+J2w08IjYT2C2vgENAhXyuFqrbRNu1SKmZK/0AOpuG e4BtdQlRJQdWur8FdYqxSMWL2PyGE949C9j654s+r2eMCSP355QI9rkJwj/NbIxRWc+4 U7vg== X-Gm-Message-State: AOJu0Ywkuyz7Z2CrxrsyBbBX85m63fFTIl99uF/CMpbOV7B+I4ejP0+T zk8SUzY4eyWk8j71st9AGzcwxMcfG+FHcrbl2xbgMzCGqzok2oaX42KUPBrn X-Google-Smtp-Source: AGHT+IGyMz02B7fLY4s8sCvwXWByc+ZMywqXSP7h+M4GEi04y7bUEZdUvmaN7rC80yDa/c3lsmXnOg== X-Received: by 2002:a05:600c:198f:b0:40e:f6b8:128d with SMTP id t15-20020a05600c198f00b0040ef6b8128dmr802528wmq.7.1706472178788; Sun, 28 Jan 2024 12:02:58 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u12-20020a5d514c000000b0033ae798b6ffsm2639968wrt.38.2024.01.28.12.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:02:58 -0800 (PST) Message-ID: <3e83f21eb4e35be0b43e2e40f79920d1b0d00dc1.1706472173.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Jan 2024 20:02:52 +0000 Subject: [PATCH 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 Sun Jan 28 20:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13534628 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 CAF843C471 for ; Sun, 28 Jan 2024 20:03:01 +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=1706472183; cv=none; b=PGDhUp6kuoTqG9nal0gWBhd7U+PkWnPlL047j3T7KlYSc7ELsdl5pubidln7NvXwb790F50E26va8+AeEzWN3CROulwb50wyWZ1I/3S5i3pAvBDGAinhiImjl93u5kdb9tAc25du0DJRRwxjbBtDTBMUzbSOqLa2vJ84gfOpI7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706472183; c=relaxed/simple; bh=qs2JfaacomBYZSJbBIC0nQLE5azEC+6LeTMFhMZ7orA=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=nWsA9I6daTcV3VxXoiz9EEQTOQKx9BsqKtQikg4hDeb6rR5fWhiX4152QXVBKTb9o7+1S19EMjABIEtT/kjhqOTmF9wq2vOCRRIN5pYV3ZPpE77iNsBEhMdHn+7QwZ3PxM6Z8fJIaZaTUo+4LgJgYTHnlJs6VXTm3i6ndculrCI= 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=eeJttMQa; 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="eeJttMQa" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3392b045e0aso1904980f8f.2 for ; Sun, 28 Jan 2024 12:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706472179; x=1707076979; 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=eeJttMQaR3ie7i0NNAev3TV5OgoL5Oj0GKrafth8N3FLLIkPeM8E6JQO00Jz0JgiMb xVb8ZE/+Jo6Q4AdZnaHDwrpYTG8DzTDMuvdQCmozNAy5nCNB/AT+QJY/QNviVRvNQmPJ HTpXeo4EqdLNWHYkteHn3vKBYv0yM7D+ILqlh0uaGZi5UkODBN6L6J5yhw2HjMHRfcu0 /os/RZsv0As/cCSr/SahuNhNVWWvNpMprSFGgymOQ8hQUdkSaXtWQgyP1Cp/p8NAEuhl 5entDW7inHX67DAb5j3aYJMX3jVLwJSWntmj4S9tm0CnAVzD2V/574tFVM7Qf+WBUiGE wQKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706472179; x=1707076979; 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=cEvCn6+Kvu0wvJ6wwyYvURW+xcTF1lXxdPWmd5fTOsIIpmXNYJOsHQXjh0u+6lSRfn icAkTcSB8lIyD5J6JYwde+SJG8qc3rtRF9FXUSyewerEAM9yz2W91zJ+29fElZwuO+vC 0DF9l0ZjMiPRQU2tMgBMsJjbypSNi5gb/ELLLvEc0ajj7e2upL60/neqHLqmsFZS1dNr r5DEckma/ac8fMSds5YxR/eKyNlxK4q3U+ZgixYfFVbp2h0h56W1Zx970Xd1Hk8e83C4 BGV/qvCtdnGUPE4XCCFEAeSPxh4/m0z7ZG6nX1xWsZ3v9AGIoBs2ahsJIhb3AkggnDRO LF2Q== X-Gm-Message-State: AOJu0Yzxuo/60CnRr/j8X9p+WAkSLGhw5X74/XoL244AAv2SX/QQswkk AIrvA2/b91LnvCTpiI2y9mC1wQjdYrvwKoVQoGwVascXR7Bb9xlkrfCDpYiT X-Google-Smtp-Source: AGHT+IEzRBRbvjVQ0FSBv/lg31Xku2CLjdzKfodWFaLfEsolNUCnF10eM6poTX7DmcLrbxDQOHfqkA== X-Received: by 2002:adf:f145:0:b0:33a:df29:eba2 with SMTP id y5-20020adff145000000b0033adf29eba2mr2867515wro.65.1706472179325; Sun, 28 Jan 2024 12:02:59 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v2-20020adfa1c2000000b0033921f48044sm6305822wrv.55.2024.01.28.12.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:02:59 -0800 (PST) Message-ID: In-Reply-To: References: Date: Sun, 28 Jan 2024 20:02:53 +0000 Subject: [PATCH 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