From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795989776; b=iWf3jn1nrrW/hqmUu7CkvSqKSOrrDwp/9N2PXbqxNhJh+E6ndmiAo1rIi7ie8xmamxVh kmDat1dUzdA9BBbYnRff/NVdmxGR+l+MAb65ejMlM7W7lQCPHkWAmgE1C3AHFFAj19ynz 95Bqs1+xr8qzpLZjK5JI/EDAyC7oyR1xefQot7p8BuM5NbEimPhZylqjUId5oBmsvAuZB OMaWVuYkIF/AHou4EuWnYsAFLqh4Lfxy2Guk1N/O08RaoQ7MgPJEbBt4zK3pdhG1he0fV nDp4D16DxDT47gaiWqO3wb++Az/8ojZrujVtKkPOgj9ftoCTOKW0L8uof5KGh+VH6Uw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795989776; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To: References:From:Date:Subject:Fcc:Content-Type: Content-Transfer-Encoding:MIME-Version:To:Cc; bh=LGsbksFGLwRLagcOSxON9LgqxVSB64HzVBKnaOslnFA=; b=2DlmO8E9xh3PsDXIc2IW8EKDWCqP9HpY2FOqXx551qDzfW03P5BBZMANuj3RWvcAq4mE QsZrlZckn9Ce20LaLIgKEdnZTPulLFEux+ZCVeednyv39GMk3YSL/fozz1kB7RyELnTj5 7wkKuZQceZqIXeO4Xfyp7sGfH5UW9He7bGyucEix41WiOiHnEYPXPDKukzdNrZ1TBnrLq 6CZoQO/2GxdtWTXJ1IbTZQHSTz6dd6qFDkP5VUiR3+VNqWQhpJ9RZHtnrdvnX3DbbJK2t OReWS6BvQ0ADkkfsWQ3yE696f+q034Lyf6cCRG8Ngj5b0rNMa15j5iqa7LIHoKjygiA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=l5z5gJbh; arc=none smtp.remote-ip=209.85.222.172 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CB0D606A32D for ; Sun, 29 Nov 2026 22:02:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5CB0D606A32D 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.a=rsa-sha256 header.s=20260707 header.b=l5z5gJbh Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-94961bfe1a0so616491385a.3 for ; Sun, 29 Nov 2026 14:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795989775; x=1796594575; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=LGsbksFGLwRLagcOSxON9LgqxVSB64HzVBKnaOslnFA=; b=l5z5gJbhkb43eDRJxYcIERbUDvgi6UaQznkteHRbQap4cMU//Aw5G0lKE+8Xr9gY1D Xh381zeJFQ8E07MqC9USLPj9ovw44wPIIAA/MSjFxN1uM2avEEeWcZucPLOmnrXKt5jC b02Wt9GTSBqz9Ve74G15IICMSg32gvbB5F+yEIpymI+tJLYevXmT9VQ2A0JhDB36vAZ7 pkWYFZrlgxU9YG27fJAS5LJES3Jn2/ig/WVt23pwfZMfzEusbMpw7h0LPY8q4DOmL50V XEP+v8fAPIAKb8Mnp4J7jpxfW8mCcNRcJkUVff04TRsOBek1BcRJEQwnXmgv8ET9MqEQ XIqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795989775; x=1796594575; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LGsbksFGLwRLagcOSxON9LgqxVSB64HzVBKnaOslnFA=; b=PGkwye27jv2l+CfDUVgyJPqjccAg4YCWdkexHIzyiYMuEKD7Iyt4QoSdR96B8UAtc4 6FiZJTlv6OI77RWYduTdrmH0UTEBCigSj7EdjjuVus/VD+EGcx95/3ntf4FzWg+Sy8/S hiAqD0brEX8VO6grtkuLUqcIUYYHJMMKvugUbGYS7d2y0qz12xj/E2C6Khwfr5TuA9+E NkKwFuDVGmFVH7o1bI1Rne6wgs3Wose/9SS5OLcqIIRUKSCV2hN4J/68Yo8IaM3LRkPG wsiKRJADz5cOiUnyYA1cy4lB3pRvqQ0h7XYL7TcVPanGTe/jEFdyWi16iQ6kXtK6dJET 74gw== X-Gm-Message-State: APuU4Z+f7GCwARDYeelU0LSgSgUk/NtvzTWsray+7lxN4mR9uZ9NQXGr NzJZltiaKBtAJJ1nOioO+xuHDKFBNjmwAdLqm7fmjqMmSW4OdBbNMBTsJnETegDu X-Gm-Gg: AZFdTZeUARznrVd82tAfFL1ErWjZPpLKGq/bzOhk/0jqf/kXczh0Q85QEgK8cKmfRs9 7zO5JaHLxCYWX3iVUM1umRIJtyg6Yp+SMm2HH21MiIuuxtNf/OpIEsBak9tChCKebpVrdm0ajXn OZAFa/fyK1shomjHPIatWIKL2kTr7DCbY7WtwULPFHHPDMuELYnqb5KZpq7Dl/iE79f9K/u8POQ RgS/XM7QPcG+3YTzZ20UUGG7h7Nm33wruH9zt8qNue9uTclw4ESWvAZTyNZ6O2e2OFDsP+1BG6e Yb3H5cbBcOscrJ94XEEjT10GdB5MRT44VOP28ltYOwCY7WghERMW9e3dILAvXCxrCe3Bcs13ht4 TE8VAd2R6MMC4mhHOWRFLdSPgD8avwLb/9aDR6ZnfNIWCtp6pCwvter3F3AXi8ggA+ZkbqB7vAI qKjf4zK8JGM1/mskpV+bfztbySTkc2M/os5bJDgnS3ycssW57ncT3nacIt7Z+vnVTNRBivErvmF OFXxAQqqX2hDxMpjZZ8OW6N+ixtAIjnaowrgBbk91cWM8fM9MF91k9VOFK84tnSjZvUf1tFSZwK HKyZxqwphEIB7HzsPw+piVWHDeawvcw= X-Received: by 2002:a05:620a:29c5:b0:93f:2f37:2e5f with SMTP id af79cd13be357-949ba9e35b0mr5670926985a.30.1795989775086; Sun, 29 Nov 2026 14:02:55 -0800 (PST) Received: from [127.0.0.1] ([20.49.62.214]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb41a341sm2392060585a.37.2026.11.29.14.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 14:02:54 -0800 (PST) Message-Id: <005c3d4428442e930935341e246d971f0f7883a3.1795989773.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Yoichi NAKAYAMA via GitGitGadget" Date: Sun, 29 Nov 2026 22:02:52 +0000 Subject: [PATCH 1/2] submodule deinit: handle regexp metacharacters in names Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 To: git@vger.kernel.org Cc: Yoichi NAKAYAMA , Yoichi NAKAYAMA From: Yoichi NAKAYAMA 'git submodule deinit' internally calls 'git config --get-regexp' to determine whether the configuration section for the submodule should be removed. Since the submodule name is included directly in the regular expression, names containing regexp metacharacters may cause the `submodule.` section to remain in the configuration after 'git submodule deinit'. Change the arguments passed to the internal 'git config' call to retrieve matching configuration keys without including the submodule name in the regular expression. Signed-off-by: Yoichi NAKAYAMA --- builtin/submodule--helper.c | 26 +++++++++++++++++++++++--- t/t7400-submodule-basic.sh | 16 ++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 461b682d0d..a09afd6630 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1589,6 +1589,8 @@ static void deinit_submodule(const char *path, const char *prefix, struct child_process cp_config = CHILD_PROCESS_INIT; struct strbuf sb_config = STRBUF_INIT; char *sub_git_dir = xstrfmt("%s/.git", path); + struct strbuf **names, **ptr; + bool found = false; if (validate_submodule_path(path) < 0) die(NULL); @@ -1649,11 +1651,29 @@ static void deinit_submodule(const char *path, const char *prefix, displaypath); cp_config.git_cmd = 1; - strvec_pushl(&cp_config.args, "config", "--get-regexp", NULL); - strvec_pushf(&cp_config.args, "submodule.%s\\.", sub->name); + strvec_pushl(&cp_config.args, "config", "get", "--all", "--show-names", + "--name-only", "-z", "--regexp", "submodule\\.", NULL); /* remove the .git/config entries (unless the user already did it) */ - if (!capture_command(&cp_config, &sb_config, 0) && sb_config.len) { + if (capture_command(&cp_config, &sb_config, 0) || !sb_config.len) + goto cleanup; + + names = strbuf_split_buf(sb_config.buf, sb_config.len - 1, '\0', 0); + for (ptr = names; *ptr; ptr++) { + const char *subsection, *key; + size_t subsection_len; + + if (!parse_config_key((*ptr)->buf, "submodule", + &subsection, &subsection_len, &key) && + subsection_len == strlen(sub->name) && + !strncmp(subsection, sub->name, subsection_len)) { + found = true; + break; + } + } + strbuf_list_free(names); + + if (found) { char *sub_key = xstrfmt("submodule.%s", sub->name); /* diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 345c257829..2b3aff4cb1 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -1283,6 +1283,22 @@ test_expect_success 'submodule deinit absorbs .git directory if .git is a direct test -z "$(git config --get-regexp "submodule\.example\.")" ' +test_expect_success 'deinit with regexp metacharacters in submodule name' ' + test_when_finished "rm -rf submodule-name-with-metachar" && + git init submodule-name-with-metachar && + ( + cd submodule-name-with-metachar && + git submodule add --name "(" "$submodurl" paren && + git submodule add --name "[" "$submodurl" bra && + git submodule add --name "^" "$submodurl" hat && + git submodule add --name "$" "$submodurl" dollar && + git commit -m "add submodules" && + git submodule deinit --all && + (git config --get-regexp "submodule\." || true) >config && + test_must_be_empty config + ) +' + test_expect_success 'submodule with UTF-8 name' ' svname=$(printf "\303\245 \303\244\303\266") && mkdir "$svname" && -- gitgitgadget