From patchwork Tue Mar 12 15:55:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13590243 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C92C558AD4 for ; Tue, 12 Mar 2024 15:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; cv=none; b=iEbfo4SI9hycOpqb+eChnMB7RwsFfWjBq/Bz/FMFYWCUWSO5S9cFKEssqz3hJHo7Q48ZEREKUp59uQrKk2+9gPm7HuSvtJvnsqNzNzwQ36Fei3q3oonOpZ0YHBzJVTMx0KwsUMldsgdgWeOsasPNwkIyLNh9NLqq5ZLkoW4pWTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; c=relaxed/simple; bh=fxYyDC8OzIaArvqfrguKgyDnp3O4i/e8FloEHfVGExs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kUDueJqvRcr14CL3UYEpE6VNJqH4pBfj7+stactWJtMYvFEv2rtVk8JLoMdcsXTmGn2X6iASCHbhCoAeGVEkuKASNPVzhZ8OqKa57gtlBT2Ylkog2RN1c10ek8aaXstFJSjxtwkjnbP7VPSY3iFfM/Ic8xzvosSZdsAayH1Mfdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=Ni9JFdEr; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="Ni9JFdEr" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710258954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=35VwkdjCMUKWvPMNgVyBpq2mZyx4ACeeruGwIiODmYM=; b=Ni9JFdErtAFCrjo0o5BBUg7+kXBNPWNhYuYv/1vFMm7ZCRxbm9BIAofOimtZtURdWawtBk PKr8shPKIpu+yoW/fMlUgVqxIrlxMKRwrEb2C5NxOCAn4eGXUGe+ikeLIbbFISSYkaGDpM E902+fecUma/vRFuLvf4VdHDjz0Njn4K6WCU9AFMeDiAlj3sqOml/WvC8ftsXg6u8N87bl Zp9bLsO4nKLPaLwIkxqfPMb1rog2ELp2HIF99zNgtlpR6POUitcABWAT93XYbWByWPlVBy fKmR4GkxJjHSQD8ggwIaqgQQ/FLNlNiST9IE580/VYc5PJN5qvHJZuuwECfJ1Q== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 1/3] config.txt: describe whitespace characters further and more accurately Date: Tue, 12 Mar 2024 16:55:44 +0100 Message-Id: <1c670101fc29a9ccc71cf4d213545a564e14aa05.1710258538.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Make it more clear what the whitespace characters are in the context of git configuration, improve the description of the trailing whitespace handling, and correct the description of the value-internal whitespace handling. Signed-off-by: Dragan Simic --- Documentation/config.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 782c2bab906c..4480bb44203b 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -22,9 +22,10 @@ multivalued. Syntax ~~~~~~ -The syntax is fairly flexible and permissive; whitespaces are mostly -ignored. The '#' and ';' characters begin comments to the end of line, -blank lines are ignored. +The syntax is fairly flexible and permissive. Whitespace characters, +which in this context are the space character (SP) and the horizontal +tabulation (HT), are mostly ignored. The '#' and ';' characters begin +comments to the end of line. Blank lines are ignored. The file consists of sections and variables. A section begins with the name of the section in square brackets and continues until the next @@ -64,12 +65,14 @@ The variable names are case-insensitive, allow only alphanumeric characters and `-`, and must start with an alphabetic character. A line that defines a value can be continued to the next line by -ending it with a `\`; the backslash and the end-of-line are -stripped. Leading whitespaces after 'name =', the remainder of the +ending it with a `\`; the backslash and the end-of-line are stripped. +Leading whitespace characters after 'name =', the remainder of the line after the first comment character '#' or ';', and trailing -whitespaces of the line are discarded unless they are enclosed in -double quotes. Internal whitespaces within the value are retained -verbatim. +whitespace characters of the line are discarded unless they are enclosed +in double quotes. This discarding of the trailing whitespace characters +also applies after the remainder of the line after the comment character +is discarded. Any number of internal whitespace characters found within +the value are converted to the same number of space (SP) characters. Inside double quotes, double quote `"` and backslash `\` characters must be escaped: use `\"` for `"` and `\\` for `\`. From patchwork Tue Mar 12 15:55:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13590242 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C93107C0B1 for ; Tue, 12 Mar 2024 15:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; cv=none; b=i1iqmBHbiIQy4crqAbFBb0vN5b0ZXc5qiIPlDIYASN2hL6oKeAhSzRINud4M/8PVoMwXgMbk7/ylFdTmmM/WDXtWNOqjf/wyFjFzl33uIKlRgh/KmE61VrtmDEF0MUhxrp1SBWmuL2SEQgYas1zFmX0s6lo1iOJY7h7B1ZzCfc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; c=relaxed/simple; bh=29KcRF33IxbK5MZxSNgIpqgLPw+6y2SKM7jHbfEHqMM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dTbJoKU0wazc6CZ29XvdtdfWWKf2iG87Tcna8Nh0W3ggZhSUzZuiZyTORiCWmQLHLV+6jPUJPeB2pl2nnb1bhWHjdaQbFGwvQmkr0Nv2we2o9nF1ave/60avqx6kWJAR/xE8mvddBYbx9fupPkzjevFN1hmMV6j3Nd1G4Ey6B14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=OOrJP4wM; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="OOrJP4wM" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710258955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+WJlvNU/UzRZUIYPMfAJI7eINsbaYYpMABdpOQ5bnHc=; b=OOrJP4wMFx2Gy2Bcu4TxJbx/mWe43Q+iSx86OnX/s0MAFrMgIyFCe0/1oVwkSL0avWcWkI 4zhFPDedSvMmzxcQPAfNJscTXnaOnctxhASVqb+6Zg1nA3sxJbHshGZJ5KtZf2GJyeeKw2 tPDp6ZDkCcJ1kPSBQ9prpa7VaBypUvRRjTuV3pHEWjV1EtNbqCXD96x0MTBSXETEa+f/Cj 41OzECKyd6trxodJEBWbbk4ZEGstHRhwl9kqoj78t63N26z8/yqmiTxTtPyoRBcwHFu1Ye /BPjyRMfQlqrWkM6yg/iGDUUQQJTvMLs0v1AAoh6Comjx83MvODr0NGHeStNhA== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 2/3] config.txt: perform some minor reformatting Date: Tue, 12 Mar 2024 16:55:45 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Reformat a few lines a bit, to utilize the available horizontal space better. There are no changes to the actual contents of the documentation. Signed-off-by: Dragan Simic --- Documentation/config.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 4480bb44203b..2fc4a52d8d76 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -58,11 +58,11 @@ compared case sensitively. These subsection names follow the same restrictions as section names. All the other lines (and the remainder of the line after the section -header) are recognized as setting variables, in the form -'name = value' (or just 'name', which is a short-hand to say that -the variable is the boolean "true"). -The variable names are case-insensitive, allow only alphanumeric characters -and `-`, and must start with an alphabetic character. +header) are recognized as setting variables, in the form 'name = value' +(or just 'name', which is a short-hand to say that the variable is the +boolean "true"). The variable names are case-insensitive, allow only +alphanumeric characters and `-`, and must start with an alphabetic +character. A line that defines a value can be continued to the next line by ending it with a `\`; the backslash and the end-of-line are stripped. From patchwork Tue Mar 12 15:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13590244 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C934E7CF22 for ; Tue, 12 Mar 2024 15:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; cv=none; b=WmZX6w4mxPDCAuJ1WmifxYWzjfJmDBgOIJqSzyZBG5PNzy7ilis1UAFZbOhF/oXkLQPiLt0mrccP6/pVTItpPEZ3sS8Qvb1A59YuS9cU/nm9R04tNE1f2+i8MDYwcCaSsT8m62jiR+sonQayJxkQ9u+NGtNNM68d2ZO/7S1nDVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710258966; c=relaxed/simple; bh=BvqiMujoQ8kyI3l/ioZkTKxS2Yukkd1T2aY5NqSZfgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sE7Zkl4hg3YPWCT7Y0y2QJgak5P6ipg1c/a/Hk1I1JSsws5cKm1dXuM0OEeMQxei2l+JA+jNU2mxs9DRd1f4SOj6RIABNeA791c8SB7qHk02GNoX5ZEdaITojturbnslWc/2KuBBcuIqJubY+5UNAqOPp6KUTsyK3y7fiyncpxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=yCP7sig9; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="yCP7sig9" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710258955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eSBYn12Ga7Dmc0uXGe7sYSko6S++U+DD2LwLST2vic0=; b=yCP7sig92GEwVIsyRPW4x2fyZv6K/NrchloXWigofAvGrwirEdUFP8Mz+lndtI+WEfLOre 1H9HkQ/5Y+Vau+ydiXt3OP8h+PBq9s+cfY/TlN8Srya/0LkSaKQrmXQjBbFzNRPUsGwKDs kurSCi9TMXJmXuziIF57TIvlEgVUXhN345jv95CpGGHEF1R9G2Slf9mRZJuY3OtaA5mYyT AkqT0F2tYANnolBcbPnHTKr3Y9OLCxbGGlG+dXv93+BrA2q4i2qsN7BoKxmmMUZbo37v/H Gy/ZGkB9MukJH8qxM7udbKpssmaVveYHZ+OgT6fL0qHSKRbcUQ9LpdXByuviUw== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 3/3] t1300: add tests for internal whitespace and inline comments Date: Tue, 12 Mar 2024 16:55:46 +0100 Message-Id: <292ab942c38de44476c6c5bf045c375bf4f6a70d.1710258538.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Add a couple of additional automated tests, to improve the coverage of configuration file entries whose values contain internal whitespace, or have an additional inline comment. Signed-off-by: Dragan Simic --- t/t1300-config.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 31c387868708..589af5e81d61 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -11,6 +11,26 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh +cat > .git/config << EOF +[section] + sparse = big blue + annotated = big blue # to be discarded +EOF + +echo 'big blue' > expect + +test_expect_success 'internal whitespace' ' + git config --get section.sparse > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'inline comment' ' + git config --get section.annotated > output && + test_cmp expect output +' + test_expect_success 'clear default config' ' rm -f .git/config '