From patchwork Thu Mar 21 06:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13598410 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 CBE3A6FBF for ; Thu, 21 Mar 2024 06:06:13 +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=1711001176; cv=none; b=XYI/fL9caYjfobcHyANDMmQIb2o9JruEaEG3P+jL3Vb+AwIp/0k9Lz//qrIKMzJ+Q5JxzCPWXUr7vr/zIZqaikZLwh58pIiF/H/aWSed/YR+/5rquQoZkOOHPOgT4BkjmJTmYRZLHrNu5WfvQvZPOfuGRS6x9YRIHlpZYGtdObM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711001176; c=relaxed/simple; bh=PbPk3NIMzhXiXJyVumbNcXJRGAfseVYC20zykUn6q6Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R7r6szam7xxyJcN0iTvhUnjNTGmZGAkzd7u1MVZ36wYPNSvFmsZxWfz02uQTC3fLklpQbx3LzBP5g6Hr9CM+sB/SflHM9yxsybJDMX0Tu7uYBNmGFHsP1x5zNHyvtcsAQVEbrbY6D3dr7v2ooNbNZ4Yqe1v7VX6akbL7YyembOo= 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=doBLsCQ0; 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="doBLsCQ0" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1711001171; 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=Z/LBknPH1gaLtWwQGAzbT3Yk44YXNyWf55DbrqK7VoE=; b=doBLsCQ0FCrG5YK+MOZHQFo+N2U+kcZMv9UbCigwynSEylwIiGEROuXLfn5UBLRBXgRSAn IHRibnGT4lHWRcWo+SFhz3EEW7TMqfjPzYM5zCxdJbvo11cQYLxCMpo0eFBxTU5hcUcZNU CFaKPOwlJ5gJLzODFfQEE7Ir7fqnAJTsjD3QS9sJxj8AHPrT9UQAbWc7EdcEZg4wuGLj3b w+iCq2oxO4tUx8rzOij79BCYa69q1EEBOhHJfoMJv/1xRMrjf7d8Gghw+nRpVjONMGIxah BnoyCcnTzRD2q2mCMGc14HoaihRDF7+qDunRUF2PyF40ho48KbZyHFFQoxjzCg== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de, sunshine@sunshineco.com Subject: [PATCH v5 1/4] config: minor addition of whitespace Date: Thu, 21 Mar 2024 07:06:05 +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 In general, binary operators should be enclosed in a pair of leading and trailing space (SP) characters. Thus, clean up one spotted expression that for some reason had a "bunched up" operator. Signed-off-by: Dragan Simic --- Notes: Changes in v5: - No changes were introduced Changes in v4: - Junio responded with "will queue" in v3, [1] but this patch hasn't reached the "next" branch yet, so resending it as a reminder - No changes were introduced Changes in v3: - Patch description was expanded a tiny bit, to make it more accurate - No changes to the source code were introduced Changes in v2: - No changes were introduced [1] https://lore.kernel.org/git/xmqq5xxhl8gs.fsf@gitster.g/ config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.c b/config.c index 3cfeb3d8bd99..a86a20cdf5cb 100644 --- a/config.c +++ b/config.c @@ -869,7 +869,7 @@ static char *parse_value(struct config_source *cs) continue; } if (c == '"') { - quote = 1-quote; + quote = 1 - quote; continue; } strbuf_addch(&cs->value, c); From patchwork Thu Mar 21 06:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13598411 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 7DE7A374C2 for ; Thu, 21 Mar 2024 06:06:14 +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=1711001176; cv=none; b=Y06j6VU/NpFJYC4ATbYqdRO1ENDQ5Cq6rud6mljKWmQlsiv6tj06OCUmpNCZ4nUUMTivdrTB5poUhoC2nleuv38nz95iuinDTad7CVJVs7QFEWaVOE7ke+vlUmkCUYssZg2RgzU3hvKQpWAP/CI+0UakjCcPJjKXJ5nSiEnEwG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711001176; c=relaxed/simple; bh=m3bP3NxHpn3E8B4qXWIIpWpoj82k8351tM7ntD4Co9E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f8UZCN0yor9jiLqbZ6UmHoF3NWTCEU+YadhMEfUE4yzrNjBrFJ+CT2e11WeBcms1Fsu+QeveaikMJlor0bY6yg29ic15X7EPV1/w2xNFWa0tMFQhZKu9zIGSLQLjvquGSIAE+/BSVLhzPD8XqU76gNRVoRedDBtmIfBaaHIfQz4= 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=Z8Din6sw; 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="Z8Din6sw" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1711001172; 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=bqHDX8FvpsHnslgD+qNo1LXSZbs4TlLjOy76Y5P/aKE=; b=Z8Din6swTpq0YnoJs3fXwIazDziJNS/GKdOerwo/FN7HOwSkkRNUWOliYBLlG3fqXA1muq hyGm5kcM0vzpXBTNwP5/JKPndgHgcdKPJxadAo3dtWWMcQcVcTyM6ktARErbxIN1mkTH/X CdRvrQprdVbS+uuHapx+MJfrFKl7ps8PqYUYoFp02fJZ9mU2cyGkmXmw7Z1gHYl/GWNPKA W6hfrS2zugw6hmJd/FCkaEqMaXSWLeGzSPba2HZZQ2KGWPJEhoV/kVGxCVYM8fqL4RNGU8 zi33L4fNqqmRHl113zFwGzjmmvN7eou9t+lc+dTJUOYhNTSkGGLJ4ntkBDx96Q== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de, sunshine@sunshineco.com Subject: [PATCH v5 2/4] config: really keep value-internal whitespace verbatim Date: Thu, 21 Mar 2024 07:06:06 +0100 Message-Id: <36393da367dc6af7e4f045c4804309cb8cb04378.1711001016.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 Fix a bug in function parse_value() that prevented whitespace characters (i.e. spaces and horizontal tabs) found inside configuration option values from being parsed and returned in their original form. The bug caused any number of consecutive whitespace characters to be wrongly "squashed" into the same number of space characters. This bug was introduced back in July 2009, in commit ebdaae372b46 ("config: Keep inner whitespace verbatim"). Further investigation showed that setting a configuration value, by invoking git-config(1), converts value-internal horizontal tabs into "\t" escape sequences, which the buggy value-parsing logic in function parse_value() didn't "squash" into spaces. That's why the test included in the ebdaae37 commit passed, which presumably made the bug remain undetected for this long. On the other hand, value-internal literal horizontal tab characters, found in a configuration file edited by hand, do get "squashed" by the value-parsing logic, so the right choice was to fix this bug by making the value-internal whitespace characters preserved verbatim. Signed-off-by: Dragan Simic --- Notes: Changes in v5: - No changes were introduced Changes in v4: - No changes were introduced Changes in v3: - No changes were introduced Changes in v2: - Dropped the "Fixes" tag, as explained and requested by Junio, [1] because having such tags actually doesn't help us in the long run - No changes to the source code were introduced [1] https://lore.kernel.org/git/xmqq4jd7qtg6.fsf@gitster.g/ config.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index a86a20cdf5cb..5072f12e62e4 100644 --- a/config.c +++ b/config.c @@ -817,33 +817,38 @@ static int get_next_char(struct config_source *cs) static char *parse_value(struct config_source *cs) { - int quote = 0, comment = 0, space = 0; + int quote = 0, comment = 0; + size_t trim_len = 0; strbuf_reset(&cs->value); for (;;) { int c = get_next_char(cs); if (c == '\n') { if (quote) { cs->linenr--; return NULL; } + if (trim_len) + strbuf_setlen(&cs->value, trim_len); return cs->value.buf; } if (comment) continue; if (isspace(c) && !quote) { + if (!trim_len) + trim_len = cs->value.len; if (cs->value.len) - space++; + strbuf_addch(&cs->value, c); continue; } if (!quote) { if (c == ';' || c == '#') { comment = 1; continue; } } - for (; space; space--) - strbuf_addch(&cs->value, ' '); + if (trim_len) + trim_len = 0; if (c == '\\') { c = get_next_char(cs); switch (c) { From patchwork Thu Mar 21 06:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13598412 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 E9722381AA for ; Thu, 21 Mar 2024 06:06:14 +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=1711001177; cv=none; b=YknuqodBChBF3VephZ1xEPhBa9B4Vk8AxDau5N4QY5Lveh2qrhtwEj5wEwPJ24JWo8Q5FNXcji3g6YZOVDX/c9OtLDJg84vse+jKfvcvRs22KUkn5KUB/NlS6bNYWE4lDwBH+j2BTyyVuGJ5LRFBYxrF7CNY4FtBnvpC4IduY4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711001177; c=relaxed/simple; bh=g34D15xnHJH6jRQSWYbeDCeK57+IoI2M64sqVpnnNS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YtxdVozpjrwu9mfrMwubRyP8OlJTtRsvewEQUlHSGcVzER0p3QcyCkDu44AIONaIx2Gw36baUGHW3ElAUvOHLAuTTlRNoN4UnFdWib8RmA3Cnp4A/MXYPXi0RvXyd6X3HEJSkiYEhD0GW9AZLOHZ3TV6jzV15LTEDOEPYax0xVk= 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=RPIJG7H0; 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="RPIJG7H0" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1711001172; 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=3y/RipEssvh4IRhVq1OXyjN6DSPhYeLHbJ2t6v0eikk=; b=RPIJG7H0iZPiJ0m66uX3dcQHqDJb3mNMNW/X8ybIMpTok2RZaHPTZj50raDVXy7mnQ5ijm 6dm4sPf6vlndyiyOuoxS2KfX9UDEmwly5n1/zl2X3Vi2ru4Vd/IEC9Iw010rRAmvGMOrKx no20UFZFzvYWh9d1sFYqiKS4EwVAu5no1Gw3pudWITPuaml5MfGSBiJtzceEKvAL8DUwzm 0w90ccAMn2dV/gYyfH/m1Iu6/dPQMycdwaRMZWVoRVEXFyvx8geJgsYGghdom4yU1/KweP Y3zeUOH2beYDlQcrplTdZZSQ4zzhdq41fPy3J/mqNnYBvS+clGTUAfp66xE/FA== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de, sunshine@sunshineco.com Subject: [PATCH v5 3/4] t1300: add more tests for whitespace and inline comments Date: Thu, 21 Mar 2024 07:06:07 +0100 Message-Id: <9110797a7d9daa7f3f29a79f416a01a6355cde82.1711001016.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 handful of additional tests, to improve the coverage of the handling of configuration file entries whose values contain internal whitespace, leading and/or trailing whitespace, which may or may not be enclosed within quotation marks, or which contain an additional inline comment. At the same time, rework one already existing whitespace-related test a bit, to ensure its consistency with the newly added tests. This change introduced no functional changes to the already existing test. Helped-by: Eric Sunshine Helped-by: Junio C Hamano Signed-off-by: Dragan Simic --- Notes: Changes in v5: - Replaced the HT escape sequence with a literal HT character in the configuration setup test's invocation of sed(1), because it may not be portable, as pointed out by Eric Sunshine [6] Changes in v4: - Improved the added configuration setup test, to make the included leading and trailing whitespace characters more robust and easier on the eyes, as suggested and outlined by Junio [5] - Expanded the patch description a bit and improved the wording - Added a Helped-by tag Changes in v3: - Removed a few unnecessary invocations of x_to_tab() - As pointed out by Eric Sunshine, [3] it's better not to introduce new random helper functions, so x_to_tab() was replaced by a direct invocation of tr(1), in one case that requires use of literal 'Q' characters, and by invocations of q_to_tab(), in the remaining cases that actually allow use of 'Q' characters to represent HTs - Dropped the change of the name of an already existing test, to not distract the reviewers, as suggested by Eric Sunshine [4] - Renamed the first added test, as suggested by Eric Sunshine, [4] to make it consistent with the expected way for naming setup tests Changes in v2: - All new tests and one already existing test reworked according to Eric Sunshine's review suggestions; [1][2] the already existing test was reworked a bit to ensure consistency - Added a Helped-by tag [1] https://lore.kernel.org/git/CAPig+cRMPNExbG34xJ0w5npUc3DDwxQUGS_AQfam_mi4s53=sA@mail.gmail.com/ [2] https://lore.kernel.org/git/CAPig+cRG8eFxepkaiN54H+fa7D=rFGsmEHdvTP+HSSaLO_6T_A@mail.gmail.com/ [3] https://lore.kernel.org/git/CAPig+cSLb+Rsy81itvw9Tfvqv9vvKSPgO_ER9fWL04XZrgFvwg@mail.gmail.com/T/#u [4] https://lore.kernel.org/git/CAPig+cTVmQzC38DympSEtPNhgY=-+dYbZmkr0RTRbhG-hp2fmQ@mail.gmail.com/ [5] https://lore.kernel.org/git/32c4718d09ff6675e37587e15e785413@manjaro.org/ [6] https://lore.kernel.org/git/CAPig+cQekOLrpcK_NcL951SRZAg-1Y1aFzE0-i-uCTK_XuiajQ@mail.gmail.com/ t/t1300-config.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 31c387868708..f4bd69512ed9 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -11,6 +11,98 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh +test_expect_success 'setup whitespace config' ' + sed -e "s/^|//" \ + -e "s/[$]$//" \ + -e "s/X/ /g" >.git/config <<-\EOF + [section] + | solid = rock + | sparse = big XX blue + | sparseAndTail = big XX blue $ + | sparseAndTailQuoted = "big XX blue " + | sparseAndBiggerTail = big XX blue X X + | sparseAndBiggerTailQuoted = "big XX blue X X" + | sparseAndBiggerTailQuotedPlus = "big XX blue X X"X $ + | headAndTail = Xbig blue $ + | headAndTailQuoted = "Xbig blue " + | headAndTailQuotedPlus = "Xbig blue " $ + | annotated = big blueX# to be discarded + | annotatedQuoted = "big blue"X# to be discarded + EOF +' + +test_expect_success 'no internal whitespace' ' + echo "rock" >expect && + git config --get section.solid >actual && + test_cmp expect actual +' + +test_expect_success 'internal whitespace' ' + echo "big QQ blue" | q_to_tab >expect && + git config --get section.sparse >actual && + test_cmp expect actual +' + +test_expect_success 'internal and trailing whitespace' ' + echo "big QQ blue" | q_to_tab >expect && + git config --get section.sparseAndTail >actual && + test_cmp expect actual +' + +test_expect_success 'internal and trailing whitespace, all quoted' ' + echo "big QQ blue " | q_to_tab >expect && + git config --get section.sparseAndTailQuoted >actual && + test_cmp expect actual +' + +test_expect_success 'internal and more trailing whitespace' ' + echo "big QQ blue" | q_to_tab >expect && + git config --get section.sparseAndBiggerTail >actual && + test_cmp expect actual +' + +test_expect_success 'internal and more trailing whitespace, all quoted' ' + echo "big QQ blue Q Q" | q_to_tab >expect && + git config --get section.sparseAndBiggerTailQuoted >actual && + test_cmp expect actual +' + +test_expect_success 'internal and more trailing whitespace, not all quoted' ' + echo "big QQ blue Q Q" | q_to_tab >expect && + git config --get section.sparseAndBiggerTailQuotedPlus >actual && + test_cmp expect actual +' + +test_expect_success 'leading and trailing whitespace' ' + echo "big blue" >expect && + git config --get section.headAndTail >actual && + test_cmp expect actual +' + +test_expect_success 'leading and trailing whitespace, all quoted' ' + echo "Qbig blue " | q_to_tab >expect && + git config --get section.headAndTailQuoted >actual && + test_cmp expect actual +' + +test_expect_success 'leading and trailing whitespace, not all quoted' ' + echo "Qbig blue " | q_to_tab >expect && + git config --get section.headAndTailQuotedPlus >actual && + test_cmp expect actual +' + +test_expect_success 'inline comment' ' + echo "big blue" >expect && + git config --get section.annotated >actual && + test_cmp expect actual +' + +test_expect_success 'inline comment, quoted' ' + echo "big blue" >expect && + git config --get section.annotatedQuoted >actual && + test_cmp expect actual +' + test_expect_success 'clear default config' ' rm -f .git/config ' @@ -1066,9 +1158,25 @@ test_expect_success '--null --get-regexp' ' test_cmp expect result ' -test_expect_success 'inner whitespace kept verbatim' ' - git config section.val "foo bar" && - test_cmp_config "foo bar" section.val +test_expect_success 'inner whitespace kept verbatim, spaces only' ' + echo "foo bar" >expect && + git config section.val "foo bar" && + git config --get section.val >actual && + test_cmp expect actual +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs only' ' + echo "fooQQbar" | q_to_tab >expect && + git config section.val "$(cat expect)" && + git config --get section.val >actual && + test_cmp expect actual +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs and spaces' ' + echo "foo Q bar" | q_to_tab >expect && + git config section.val "$(cat expect)" && + git config --get section.val >actual && + test_cmp expect actual ' test_expect_success SYMLINKS 'symlinked configuration' ' From patchwork Thu Mar 21 06:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13598413 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 62EEF38DC0 for ; Thu, 21 Mar 2024 06:06:15 +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=1711001177; cv=none; b=Ib3EiQHQJPs+DbsJktvigavLi+/6qqAOodXBEvRPQDwcST6xNZQvIj9iwdC3WfFChJQ9PXp7LJ41wfIQ5YDZfZA0hQdlAjBfstzCCYl8zxLuoN99AzDdW51RIiAdNGN0yenKHgZdxvKMerYMATcSfhrLcD2bMUl9PZVSsjt4viA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711001177; c=relaxed/simple; bh=EhN63A78Fva4nHG1z0g1rRfxgtYEhdDhkAa8GK/ZfB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UkD8ytV8qsBnFqP6ODtfGozVq3GlsQJTjFAS0NmQus4/FMqbzD7Z9WCZFXeQMh2NB5mh4zgaAg4fjXyc8wcCUadxflZidwKcHlvQKiODXfaila6359JUfypDsZUamFEbDEc/nHaeRh7Y2KhCPGh7CRFC2z/d+ee48sXARqhbBUc= 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=p6vso+ns; 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="p6vso+ns" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1711001173; 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=hX6v4yHH1IJe9LS4Q9pGAonpgrmZYLYDaKIHJcZnPs4=; b=p6vso+nsroP2ISOEiLR6djYnlZRnuRzgZfzcAgID7Tp+GK2fa8pHsSKay3YSpi7LlmO/Tu jBiBLMgv2ulhrMPqlRvFBHB1w8Fj9n0w8XH2dynlsXs0+SPL+xGkeW0VTIkJyicbYGhySz 2lmT9URkfgg2rxm0OO6wCS4SV6xL+C9s3J/gVpZ/sBJwGimgEt2xx1rb/iK+BzsXPUKLxg jMqBMUTorahZAy3t7MOhqVG5vHfhJv0oUdMNOHY0vFmp1lwjKtLru5l1L2L0rlXxK51Q0V SUl7ndTwkv2MuNyRfWHoRcCG0IcnjjXy3NyKk1McS9D/IUrInN0b11xzqOeA7Q== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de, sunshine@sunshineco.com Subject: [PATCH v5 4/4] config.txt: describe handling of whitespace further Date: Thu, 21 Mar 2024 07:06:08 +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 Make it more clear what the whitespace characters are in the context of git configuration files, and significantly improve the description of the leading and trailing whitespace handling, especially how it works out together with the presence of inline comments. Helped-by: Junio C Hamano Helped-by: Eric Sunshine Signed-off-by: Dragan Simic --- Notes: Changes in v5: - Rewrote the description of whitespace character handling again, to eliminate ambiguity, as suggested by Eric Sunshine [3][4] - Extended the improvements to the following paragraph as well, to tie it all together, and to make it less ambiguous how to include leading and trailing whitespace characters into configuration option values, if desired so - Added a Helped-by tag Changes in v4: - Improved the wording and accuracy of the description of whitespace character handling, as discussed with Junio, [1][2] by taking a more radical approach and rewriting an entire paragraph, because it has reached the point where "patching the patchwork" no longer worked; I'm quite happy with the way it turned out this time - Expanded the patch description a tiny bit - Added a Helped-by tag Changes in v3: - Patch description was expanded a bit, to make it more on point - No changes to the documentation were introduced Changes in v2: - No changes were introduced [1] https://lore.kernel.org/git/xmqqttl1js1o.fsf@gitster.g/ [2] https://lore.kernel.org/git/ce041191a245ff888b1710cdcaad9e61@manjaro.org/ [3] https://lore.kernel.org/git/CAPig+cSYhYBa0NsvJCOYo4JsWzLJT9rU++U1QKA3jRB6Cptbhw@mail.gmail.com/ [4] https://lore.kernel.org/git/fdaec126df16bf6fe1c1fca9698f7dcc@manjaro.org/ Documentation/config.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 782c2bab906c..70b448b13262 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 @@ -63,16 +64,17 @@ 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. Leading whitespaces 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. - -Inside double quotes, double quote `"` and backslash `\` characters -must be escaped: use `\"` for `"` and `\\` for `\`. +Whitespace characters surrounding `name`, `=` and `value` are discarded. +Internal whitespace characters within 'value' are retained verbatim. +Comments starting with either `#` or `;` and extending to the end of line +are discarded. A line that defines a value can be continued to the next +line by ending it with a backslash (`\`); the backslash and the end-of-line +characters are discarded. + +If `value` needs to contain leading or trailing whitespace characters, +it must be enclosed in double quotation marks (`"`). Inside double quotation +marks, double quote (`"`) and backslash (`\`) characters must be escaped: +use `\"` for `"` and `\\` for `\`. The following escape sequences (beside `\"` and `\\`) are recognized: `\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)