From patchwork Fri Mar 15 13:22: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: 13593478 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 DD676376EB for ; Fri, 15 Mar 2024 13:22:18 +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=1710508941; cv=none; b=WgHUP9tv99H9rW12IS/kGbPzXk6e7JIVwABFMRJenQOr6DM7S+59jSXQnyeFTBhC3qMSMyy87gifIuE5Vok8ACktEZ41tL3wdEmGUthqK53f6VV/ZTNYA6tolAad0+4YndE03wB+ROKEH4ljytfkZxgxzp9onXZrSiXcqX7i+mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710508941; c=relaxed/simple; bh=PoyRDylxbkqm75BvNRzPLsscaHmVc1gjPmFC2S3xKjs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FLFdJ6kZ/IROelOxCd3qaFV/f7ggsaz2Uy+3IY7+lmj0wRoPvovrioS0PO7E01I+PN/LRwbTUEO5gd2iS59+vcxpxvXkpZ3WEJL13Ol7a0dokijTh0tRqVAZ1fidyquEYhOihNG6sOCzVrQBEpTXahQ1opi9QnWrjPufH4/O+hY= 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=FIBbC3uB; 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="FIBbC3uB" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710508935; 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=vRSa0NKeEtkIoLJ886cc8IDnyDtEN/EyT3ZAc9qahOM=; b=FIBbC3uBHuCMV5mCWbcAC3RYQvlRFkFdd3YjJxi7Itp7SCQVOuDdhlKkkNfIUxENT/gg3n 6QLeZZHp0i6Uusaou6ufPMPe8w6SXUNl0Hv3xAli+23tRFDQ6kS0BW3PNyln/cyahCxB1Y E7So4FlLjeZxohp9yQ7BT0W68PiOrSewGe6GGr8nO8oOP8fwBGlWCmpjpAXfRmyilOf0rF e/NChuXQPoSz7mZkSJ0YRVNOFgXYeh51SQPXwj8ldWbBrmVq8t6+Emdzj/54VfcEE7jWPq W2P9HfP2bgycdflOZK2Ndy8OTHER55MchgwJXIri3lErrc33c5j4M2vSrrlR+w== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 1/4] config: minor addition of whitespace Date: Fri, 15 Mar 2024 14:22:07 +0100 Message-Id: <33ae9976fc089fe8f59aa857373319183bf558b3.1710508691.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 In general, binary operators should be enclosed in a pair of leading and trailing space characters. Thus, clean up one spotted expression that for some reason had a "bunched up" operator. Signed-off-by: Dragan Simic --- 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 Fri Mar 15 13:22: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: 13593481 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 DD6CD376F3 for ; Fri, 15 Mar 2024 13:22:18 +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=1710508942; cv=none; b=hJOv9ORdoHzZ+tEDSMwIjWjazprNdGk8+lhAE8t1DchpBBjf026V5h4YNgZZ2bdAgFMm5G2Nqro2uWLNc4SakuTVL8Ych3ueVre6iPy25xF7yzlkD+0q46CsvK65YPGZpU5D/4qV7pJNRM6Ubnu9BALWggSaUB529daFAtctg08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710508942; c=relaxed/simple; bh=s+N0oZmfAnr/6eQYR0NNBDqkFzG+o9KMb2wCWBXKez8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QOADIS2+keCKBc4Qa0rnalNmsR8PV+j3NGNUG1r+h0zPMTqq9vy3F8IGThkgHbp3ti2X5kSdA87ZNdjvd2ehLcs5fdjlV2o3t6v979RK7RViLd/e7pWVgvVgadvhI4R/95ZXKJPAMVLNF5pzfpFVaCjnhLIHqzjhumRjnyXMPoQ= 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=tO8aFSxP; 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="tO8aFSxP" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710508935; 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=Q2kpVHoh0v7GRLWEM82TSUPDpWHyuzQgrT22rNTeQKI=; b=tO8aFSxPVKjLFnMTr/LvhEo0Ix7x1iOFM/p82UUjSHvCHonJ/V5iLoJL6n4ZtEqyEHC2s3 wTr+LBNaDVrQEk8pXQC5qGJ1XWpXAZXlLN/WAu3xJZ6IRiDm56zqs1mQZlibqeZ2IQy9oL /UuZCft7YHJIivfCHHArR7gKHBqNKvp4TbMcYThXnvJP3OPLUGp6St7LGAYHQKAgaaqv8s WJw9OvRPQDZXmrctFq9B3bZnpTHMlHXiHrke55KTdw5qMKtYMGNPU5BiLjaxqyvlPwH9nv 7kpRmwMgCKs7OPaJVkQNxCD12AeCUnrjoKRsugn/poy/xqUVJf60Lzft9Uz3Mg== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 2/4] config: really keep value-internal whitespace verbatim Date: Fri, 15 Mar 2024 14:22: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 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. Fixes: ebdaae372b46 ("config: Keep inner whitespace verbatim") Signed-off-by: Dragan Simic --- 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 Fri Mar 15 13:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13593479 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 DD69D376F2 for ; Fri, 15 Mar 2024 13:22:18 +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=1710508942; cv=none; b=l4R8f3/Qy9uW0wXl5/DywK6eWvVRCb82IvcmDZIUfcLUsjVKyLqwCfLOLSejT7SzQsRpeWrPENoAhx52WE4r+ee1rEtuabcpt7OLHEcr6xkXCNWRpP2fwiwYJ90c6oyPDRiG7svQoMYIRGKpeF2LhlyDEUoeOU4D+kBoV67fAiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710508942; c=relaxed/simple; bh=gEfBUDKX+EWZo3N3NKgqHpPTnsDGdGR/xxS11ufNp2c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ugQo5HEpoANp/sXrr3j50MR3KJCcQpL0vAPNDmRB9i0y5+w3qu5d1FWfzEGYvaqQVrPso+RSpfp1LszOrfLB14zUrUktBz5p8V1OZ9CVrGdUtpSBBQkJMS+t/AJSSMk1dvjY1R5bfI2RtA4SuAFvQRI6LOzqEmZK7fXLcrN9DtE= 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=wa3NWp29; 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="wa3NWp29" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710508936; 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=q7Gw5d1TeGDpnKKQ36qq48VDYbrVBiARUshLsZHnnwQ=; b=wa3NWp29YFPYa4aHK9YQUw9aRVG5Kh3BydDYJTLdY0xNXcHC/FPVE1VqRCajs9vkZG9wQt rTUzw46UD4ajdoLwr61j6C/B4mMQdIndZ2ilf/0OIj+6WZdTjpXXwwrCD+uqVLY9JIJ04k dXvlazOtDiyGdQ+y75zZdonxv3FqRBkNkKtSgZIg+AukHA2M7H8F8rARlr9LOA8tLAIr36 wSusP64Tw/CLFe3NmyliCSvvdCc+BgyruLNnlmK+P5QhSNbaUKMUBddd6lJECmLVt1Q7xS F3B2KupLh8GNN/rCLR++LyUxBQ9Ag20y3vLDdKyB+G68FGdkcoSn22BllJJigg== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 3/4] t1300: add more tests for whitespace and inline comments Date: Fri, 15 Mar 2024 14:22:09 +0100 Message-Id: <590731e15a01558d1bbcdfc01df4f78573138742.1710508691.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 automated tests, to improve the coverage of configuration file entries whose values contain internal whitespace, leading and/or trailing whitespace, or which contain an additional inline comment. Signed-off-by: Dragan Simic --- t/t1300-config.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 31c387868708..6eef8a48098c 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -11,6 +11,96 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh +cat > .git/config << EOF +[section] + solid = rock + sparse = big blue + sparseAndTail = big blue + sparseAndTailQuoted = "big blue " + sparseAndBiggerTail = big blue + sparseAndBiggerTailQuoted = "big blue " + sparseAndBiggerTailQuotedPlus = "big blue " + headAndTail = big blue + headAndTailQuoted = " big blue " + headAndTailQuotedPlus = " big blue " + annotated = big blue # to be discarded + annotatedQuoted = "big blue" # to be discarded +EOF + +echo 'rock' > expect + +test_expect_success 'no internal whitespace' ' + git config --get section.solid > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'internal whitespace' ' + git config --get section.sparse > output && + test_cmp expect output +' + +test_expect_success 'internal and trailing whitespace' ' + git config --get section.sparseAndTail > output && + test_cmp expect output +' + +test_expect_success 'internal and more trailing whitespace' ' + git config --get section.sparseAndBiggerTail > output && + test_cmp expect output +' + +echo 'big blue ' > expect + +test_expect_success 'internal and trailing whitespace, all quoted' ' + git config --get section.sparseAndTailQuoted > output && + test_cmp expect output +' + +echo 'big blue ' > expect + +test_expect_success 'internal and more trailing whitespace, all quoted' ' + git config --get section.sparseAndBiggerTailQuoted > output && + test_cmp expect output +' + +test_expect_success 'internal and more trailing whitespace, not all quoted' ' + git config --get section.sparseAndBiggerTailQuotedPlus > output && + test_cmp expect output +' + +echo 'big blue' > expect + +test_expect_success 'leading and trailing whitespace' ' + git config --get section.headAndTail > output && + test_cmp expect output +' + +echo ' big blue ' > expect + +test_expect_success 'leading and trailing whitespace, all quoted' ' + git config --get section.headAndTailQuoted > output && + test_cmp expect output +' + +test_expect_success 'leading and trailing whitespace, not all quoted' ' + git config --get section.headAndTailQuotedPlus > 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 'inline comment, quoted' ' + git config --get section.annotatedQuoted > output && + test_cmp expect output +' + test_expect_success 'clear default config' ' rm -f .git/config ' @@ -1066,7 +1156,17 @@ test_expect_success '--null --get-regexp' ' test_cmp expect result ' -test_expect_success 'inner whitespace kept verbatim' ' +test_expect_success 'inner whitespace kept verbatim, spaces only' ' + git config section.val "foo bar" && + test_cmp_config "foo bar" section.val +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs only' ' + git config section.val "foo bar" && + test_cmp_config "foo bar" section.val +' + +test_expect_success 'inner whitespace kept verbatim, horizontal tabs and spaces' ' git config section.val "foo bar" && test_cmp_config "foo bar" section.val ' From patchwork Fri Mar 15 13:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13593482 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 DD645376E6 for ; Fri, 15 Mar 2024 13:22:18 +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=1710508945; cv=none; b=lz08hhe9/Wp0mkybq2wqgDmDXBdmNBIOEjck35Th4i7BhPtEMrFgvqUQQTzvkcyDtg49S8dx6Fy9G9sj66AQA1iz19/laLELG03+PBTK6FlMs5qT2Wqdw46lPiZMGYJhMUBfHjefzJndp6dfzc4H0eV7LERDj0NJ8hxXDquMOUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710508945; c=relaxed/simple; bh=1Ef/rV2XBUkFYHC1H/QnmhT1MchVMEzS87Q91PftKXA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HM0RV0ugN2KOSkHPOVJ+QeVBtrU64/oiFKZAC2tqEEb+m0PPVkWtYSFoVepZ+i9hB0PYqE9byjmWjDnoO3lbfc9HWgL91bjWs30V11hu5rAYUlLff6f6zr5bMR4T6+w7WhVOOnqxbXy5izkzbPV8T1UsYnkBsKQGmsbEfWM77fM= 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=ZzhVuy11; 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="ZzhVuy11" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1710508936; 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=2A+F5zjzkW3ogS75d/ZB86Pfo3/d8eCQTXyAym7cZBk=; b=ZzhVuy11xQuJ6yQidPs6LVNsjw+HK4yibHI8wwkT5/kaCzfVqpZ3CydBTEG6kpAQPafSQ0 XEUvDI8uVtROFa6QLDmw/JQaM6ZK/D0cAfgFuoVYSNIDknxyWThdtlm0gfi7ZP4967zJC4 nzbgBW/HB54B3EOqAKF/2XOeSoO83hc11XCtnMFeGSiugdvWCKPCiciApo3lpmyENd3rHd XO44aGTHnsyLDfYgdbwhQLzGPI4sEIU8KsLEFxFXTyp0uHKwsgh6h1JqsmSOw7jMiZdzlX arPi2fK7KuyFv6UscBI6x+9kFv494J+D/zPms7O/xnyy/qRd4hXVzhDpD5M5VA== To: git@vger.kernel.org Cc: gitster@pobox.com, rsbecker@nexbridge.com, github@seichter.de Subject: [PATCH 4/4] config.txt: describe handling of whitespace further Date: Fri, 15 Mar 2024 14:22:10 +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 improve the description of the trailing whitespace handling a bit. 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..20f3300dc706 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. The discarding of the trailing whitespace characters +applies regardless of the discarding of the portion of the line after +the first comment character. Internal whitespace characters within the +value are retained verbatim. Inside double quotes, double quote `"` and backslash `\` characters must be escaped: use `\"` for `"` and `\\` for `\`.