From patchwork Fri Jan 24 00:21:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2997109A for ; Fri, 24 Jan 2020 00:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72A212071E for ; Fri, 24 Jan 2020 00:21:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZsOmGnYL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729402AbgAXAVL (ORCPT ); Thu, 23 Jan 2020 19:21:11 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45017 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729017AbgAXAVL (ORCPT ); Thu, 23 Jan 2020 19:21:11 -0500 Received: by mail-wr1-f65.google.com with SMTP id q10so5328181wrm.11 for ; Thu, 23 Jan 2020 16:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=saMlTNkKEqcBRL5aUOy1TDYQZGXm7gjU9li+Opxvdcs=; b=ZsOmGnYLhw54PL2kwNVvhW7UWETFMjS64bMk9QrFrUqIqfbm4ied0NzW/u7SXtE+uO wNLoVsvSn7kv+frRBeEfrwAMczHmdOlCcF77rDtF9Xg0Q1cYgvk6DSOMBAyJLQbXTn6a 7HA+8xyx6VXibggjf2FNuKLySWq88upcs15Y5cj4MvNP6PLxHZMa0tSxLhUnbXAtHgR4 LbWY5YDFVb6X5WpKtyXLHUh+PbPPkS5gu1hB3B5jeH6yHPSH9PIo7DeM8NCn3VgMsldY wbFBrAi8Cwr/zisNM3sdJvS5OPRr4zoCKb7NG/S6psxphJoNxiL8WWxzOwcXXeS61sA8 dPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=saMlTNkKEqcBRL5aUOy1TDYQZGXm7gjU9li+Opxvdcs=; b=l2bmZnb6HYAD3NtQArv6Le2FhyjSkRuKIz5tBY3GP0cnGx5Zu8Q3l1wLvNmpyKSOU6 lHvgNWQK6rmjWaBw7tHGeVqmo2yIC+6uZAY8XdaOkddNs0SO4Pz0wUEUGfJZiXvssBdw zOAvZr3zqTVRWp9WR8FCIYzpdMa7FJ/qqVySi0kQAbDJNh4EdP1eVKiEJDpHtZwWPpL1 RH7GX9ZHhQtMb+R0UcssEVgXH5BwQaFfOVu/QTuAk7Dq2ZPNrkipuDiP7ySZvLpLInLY M/L10a+UCgEXkVi6N2LRPCLRoqKzxibiK1s51+3khRQZxucVl7kfuD9A5KCEzRwAFjy9 9Kpw== X-Gm-Message-State: APjAAAXvfYBzh60bPlRkcNiClzCXr+i4SCWF+w2ADzJslyrY1U4NnMBz tXqGZiw+roGmTa5nWUbXDnsr9nJZ X-Google-Smtp-Source: APXvYqzxupyGKEc+reyOBQ6z6VR0oXqSZNAhQxd+lwDA19MU1O5nR10Zfc2or8ssUQv15p7PFE2yIw== X-Received: by 2002:a05:6000:cf:: with SMTP id q15mr675326wrx.393.1579825269428; Thu, 23 Jan 2020 16:21:09 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s10sm5051989wrw.12.2020.01.23.16.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:08 -0800 (PST) Message-Id: In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:01 +0000 Subject: [PATCH v4 1/6] config: fix typo in variable name Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers In git config use of the end_null variable to determine if we should be null terminating our output. While it is correct to say a string is "null terminated" the character is actually the "nul" character, so this malapropism is being fixed. Signed-off-by: Matthew Rogers --- builtin/config.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 98d65bc0ad..52a904cfb1 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -29,7 +29,7 @@ static int use_worktree_config; static struct git_config_source given_config_source; static int actions, type; static char *default_value; -static int end_null; +static int end_nul; static int respect_includes_opt = -1; static struct config_options config_options; static int show_origin; @@ -151,7 +151,7 @@ static struct option builtin_config_options[] = { OPT_CALLBACK_VALUE(0, "path", &type, N_("value is a path (file or directory name)"), TYPE_PATH), OPT_CALLBACK_VALUE(0, "expiry-date", &type, N_("value is an expiry date"), TYPE_EXPIRY_DATE), OPT_GROUP(N_("Other")), - OPT_BOOL('z', "null", &end_null, N_("terminate values with NUL byte")), + OPT_BOOL('z', "null", &end_nul, N_("terminate values with NUL byte")), OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")), OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")), OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")), @@ -178,11 +178,11 @@ static void check_argc(int argc, int min, int max) static void show_config_origin(struct strbuf *buf) { - const char term = end_null ? '\0' : '\t'; + const char term = end_nul ? '\0' : '\t'; strbuf_addstr(buf, current_config_origin_type()); strbuf_addch(buf, ':'); - if (end_null) + if (end_nul) strbuf_addstr(buf, current_config_name()); else quote_c_style(current_config_name(), buf, NULL, 0); @@ -678,7 +678,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) config_options.git_dir = get_git_dir(); } - if (end_null) { + if (end_nul) { term = '\0'; delim = '\n'; key_delim = '\n'; From patchwork Fri Jan 24 00:21:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4265C109A for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 081952071E for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lCaYAwJ8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbgAXAVO (ORCPT ); Thu, 23 Jan 2020 19:21:14 -0500 Received: from mail-wm1-f41.google.com ([209.85.128.41]:36157 "EHLO mail-wm1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729353AbgAXAVN (ORCPT ); Thu, 23 Jan 2020 19:21:13 -0500 Received: by mail-wm1-f41.google.com with SMTP id p17so98848wma.1 for ; Thu, 23 Jan 2020 16:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7DrGpQf9DDm3TBMcqcnJxyJb3N0r9XW88u+IETBgq/Y=; b=lCaYAwJ8dSr9AYyTpxLHT71omHKqcs7j3aI8KMWgCWsuGGzKXTAQ7eS03YGfIHWdlV sIgMYO3ShtyB9obqKWdRSOJ9QqKz7vpXlqvV9gy4dJ0UzMQ5AnWonnSTufNmcTZP/KWG w265gn04rBghHBrzvh2XYjgt+mHeqHdDQiM4/X6Pkvt1gLlnTHxOsPEk6vYCrYdA9cUw iTFZ+GWUCJy0svZ/LTsfzOuo2FAIYCIB1+lzUurGneei3G/gcGlA9CAsP0/V4Mui9DO3 wdI9FysaebXC+rNliJYv0jLuvn/TsZ4ElKeSygeporzR2udxtn5SIgC0sunNGCPaGze8 KNIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7DrGpQf9DDm3TBMcqcnJxyJb3N0r9XW88u+IETBgq/Y=; b=oncGuhtM0nZ8sZSZuw9Axq2q/GjI4naV19KetIezXBhfwf2+BJ8WLKeke9j1DWI9Wi tdgmq0bP/pJSGN4uApjXDvAe4UGBWrzWqe5b3EYUBPDEUoPmEgooLyT2VI3Pb4ySf3/7 w0EUn19KeA7rfFfSkwlPQQSDGsRmNDZ7mv3sRG8BFUM+rm6ezLV4uS2bLOJvGEzNq9VG ZDBb2qGAhRpfhBMmFrlF7TsswWlE/u7rzNfxldAj/XOltxZ/4H3JkclaneZiVsmtyzvJ Zz4NwydL2Lcx3By60fxaRtLYq02/fgGJ636k/tD51vT6GZOpQ1vkMaIDvawD0dli5VLP RsdQ== X-Gm-Message-State: APjAAAXJwsdFMADEwr/POHdpYDKqu2lQ4MjqEwpjGotNDM4Zmtt018or 392BwkeS2ay7Gln9q4zqVucY6Ppb X-Google-Smtp-Source: APXvYqwUoQQ5x5MMOHN7xN12pzAOr+I/dtxuFSulnos2QzhvjDfEtW00thxE2TFnvSKPiv0z5/ciVA== X-Received: by 2002:a1c:6588:: with SMTP id z130mr489180wmb.0.1579825270238; Thu, 23 Jan 2020 16:21:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t5sm5025082wrr.35.2020.01.23.16.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:09 -0800 (PST) Message-Id: <1b42f853996565ebb1304701cae6cfde8d5357b1.1579825267.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:02 +0000 Subject: [PATCH v4 2/6] t1300: fix over-indented HERE-DOCs Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers Prepare for the following patches by removing extraneous indents from HERE-DOCs used in config tests. Signed-off-by: Matthew Rogers --- t/t1300-config.sh | 168 +++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 983a0a1583..e8b4575758 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1191,47 +1191,47 @@ test_expect_success 'old-fashioned settings are case insensitive' ' test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - Qr = value2 + [V.A] + Qr = value2 EOF git config -f testConfig_actual "v.a.r" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - QR = value2 + [V.A] + QR = value2 EOF git config -f testConfig_actual "V.a.R" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - r = value1 - Qr = value2 + [V.A] + r = value1 + Qr = value2 EOF git config -f testConfig_actual "V.A.r" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - r = value1 - Qr = value2 + [V.A] + r = value1 + Qr = value2 EOF git config -f testConfig_actual "v.A.r" value2 && test_cmp testConfig_expect testConfig_actual @@ -1241,26 +1241,26 @@ test_expect_success 'setting different case sensitive subsections ' ' test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && cat >testConfig_actual <<-EOF && - [V "A"] - R = v1 - [K "E"] - Y = v1 - [a "b"] - c = v1 - [d "e"] - f = v1 + [V "A"] + R = v1 + [K "E"] + Y = v1 + [a "b"] + c = v1 + [d "e"] + f = v1 EOF q_to_tab >testConfig_expect <<-EOF && - [V "A"] - Qr = v2 - [K "E"] - Qy = v2 - [a "b"] - Qc = v2 - [d "e"] - f = v1 - [d "E"] - Qf = v2 + [V "A"] + Qr = v2 + [K "E"] + Qy = v2 + [a "b"] + Qc = v2 + [d "e"] + f = v1 + [d "E"] + Qf = v2 EOF # exact match git config -f testConfig_actual a.b.c v2 && @@ -1622,40 +1622,40 @@ test_expect_success 'set up --show-origin tests' ' INCLUDE_DIR="$HOME/include" && mkdir -p "$INCLUDE_DIR" && cat >"$INCLUDE_DIR"/absolute.include <<-\EOF && - [user] - absolute = include + [user] + absolute = include EOF cat >"$INCLUDE_DIR"/relative.include <<-\EOF && - [user] - relative = include + [user] + relative = include EOF cat >"$HOME"/.gitconfig <<-EOF && - [user] - global = true - override = global - [include] - path = "$INCLUDE_DIR/absolute.include" + [user] + global = true + override = global + [include] + path = "$INCLUDE_DIR/absolute.include" EOF cat >.git/config <<-\EOF - [user] - local = true - override = local - [include] - path = ../include/relative.include + [user] + local = true + override = local + [include] + path = ../include/relative.include EOF ' test_expect_success '--show-origin with --list' ' cat >expect <<-EOF && - file:$HOME/.gitconfig user.global=true - file:$HOME/.gitconfig user.override=global - file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include - file:$INCLUDE_DIR/absolute.include user.absolute=include - file:.git/config user.local=true - file:.git/config user.override=local - file:.git/config include.path=../include/relative.include - file:.git/../include/relative.include user.relative=include - command line: user.cmdline=true + file:$HOME/.gitconfig user.global=true + file:$HOME/.gitconfig user.override=global + file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include + file:$INCLUDE_DIR/absolute.include user.absolute=include + file:.git/config user.local=true + file:.git/config user.override=local + file:.git/config include.path=../include/relative.include + file:.git/../include/relative.include user.relative=include + command line: user.cmdline=true EOF git -c user.cmdline=true config --list --show-origin >output && test_cmp expect output @@ -1663,16 +1663,16 @@ test_expect_success '--show-origin with --list' ' test_expect_success '--show-origin with --list --null' ' cat >expect <<-EOF && - file:$HOME/.gitconfigQuser.global - trueQfile:$HOME/.gitconfigQuser.override - globalQfile:$HOME/.gitconfigQinclude.path - $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute - includeQfile:.git/configQuser.local - trueQfile:.git/configQuser.override - localQfile:.git/configQinclude.path - ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative - includeQcommand line:Quser.cmdline - trueQ + file:$HOME/.gitconfigQuser.global + trueQfile:$HOME/.gitconfigQuser.override + globalQfile:$HOME/.gitconfigQinclude.path + $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute + includeQfile:.git/configQuser.local + trueQfile:.git/configQuser.override + localQfile:.git/configQinclude.path + ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative + includeQcommand line:Quser.cmdline + trueQ EOF git -c user.cmdline=true config --null --list --show-origin >output.raw && nul_to_q output && @@ -1684,9 +1684,9 @@ test_expect_success '--show-origin with --list --null' ' test_expect_success '--show-origin with single file' ' cat >expect <<-\EOF && - file:.git/config user.local=true - file:.git/config user.override=local - file:.git/config include.path=../include/relative.include + file:.git/config user.local=true + file:.git/config user.override=local + file:.git/config include.path=../include/relative.include EOF git config --local --list --show-origin >output && test_cmp expect output @@ -1694,8 +1694,8 @@ test_expect_success '--show-origin with single file' ' test_expect_success '--show-origin with --get-regexp' ' cat >expect <<-EOF && - file:$HOME/.gitconfig user.global true - file:.git/config user.local true + file:$HOME/.gitconfig user.global true + file:.git/config user.local true EOF git config --show-origin --get-regexp "user\.[g|l].*" >output && test_cmp expect output @@ -1703,7 +1703,7 @@ test_expect_success '--show-origin with --get-regexp' ' test_expect_success '--show-origin getting a single key' ' cat >expect <<-\EOF && - file:.git/config local + file:.git/config local EOF git config --show-origin user.override >output && test_cmp expect output @@ -1712,14 +1712,14 @@ test_expect_success '--show-origin getting a single key' ' test_expect_success 'set up custom config file' ' CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" && cat >"$CUSTOM_CONFIG_FILE" <<-\EOF - [user] - custom = true + [user] + custom = true EOF ' test_expect_success !MINGW '--show-origin escape special file name characters' ' cat >expect <<-\EOF && - file:"file\" (dq) and spaces.conf" user.custom=true + file:"file\" (dq) and spaces.conf" user.custom=true EOF git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output && test_cmp expect output @@ -1727,7 +1727,7 @@ test_expect_success !MINGW '--show-origin escape special file name characters' ' test_expect_success '--show-origin stdin' ' cat >expect <<-\EOF && - standard input: user.custom=true + standard input: user.custom=true EOF git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output && test_cmp expect output @@ -1735,11 +1735,11 @@ test_expect_success '--show-origin stdin' ' test_expect_success '--show-origin stdin with file include' ' cat >"$INCLUDE_DIR"/stdin.include <<-EOF && - [user] - stdin = include + [user] + stdin = include EOF cat >expect <<-EOF && - file:$INCLUDE_DIR/stdin.include include + file:$INCLUDE_DIR/stdin.include include EOF echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" | git config --show-origin --includes --file - user.stdin >output && @@ -1750,7 +1750,7 @@ test_expect_success '--show-origin stdin with file include' ' test_expect_success !MINGW '--show-origin blob' ' blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && cat >expect <<-EOF && - blob:$blob user.custom=true + blob:$blob user.custom=true EOF git config --blob=$blob --show-origin --list >output && test_cmp expect output @@ -1758,7 +1758,7 @@ test_expect_success !MINGW '--show-origin blob' ' test_expect_success !MINGW '--show-origin blob ref' ' cat >expect <<-\EOF && - blob:"master:file\" (dq) and spaces.conf" user.custom=true + blob:"master:file\" (dq) and spaces.conf" user.custom=true EOF git add "$CUSTOM_CONFIG_FILE" && git commit -m "new config file" && From patchwork Fri Jan 24 00:21:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D1A817EA for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E0902071E for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nuh34G7T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729794AbgAXAVO (ORCPT ); Thu, 23 Jan 2020 19:21:14 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52775 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729017AbgAXAVN (ORCPT ); Thu, 23 Jan 2020 19:21:13 -0500 Received: by mail-wm1-f67.google.com with SMTP id p9so91551wmc.2 for ; Thu, 23 Jan 2020 16:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Vzbm2jbZgmjXl+MHBE3DtIUgRyeqxuVjjO8cWWLto1M=; b=nuh34G7TwZWBCQCq22YQUEd3sy4wOgy1AxYZnPvrEmDaE6dpliSka1OYnQDMYxfSww FrdaOGB7PzkaA1UE9EqEcc6a/Dj4DmAeeUYeNsyf6SlmhsRDnO7UdAkFCjSqZTUllMmX mkQvtd/r2gZnLv9jjsYjZ7gKpNG5aBPID3FZLmVt7m1uFoh5sjb55YUi8XyPU24CEVfU /pgD3lW62Rc2H/rwxLUUwy8k7IJmetJBO4EMIDC8K//Js+JiH2k6v4EahVWL44IfcwLC K6YtdAly+ZV2htC5FkHJUHewXI3WHcqtpBSDjJhaCJi9l1GdtuHN4S1vWNFGHhYx9VFG BoRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Vzbm2jbZgmjXl+MHBE3DtIUgRyeqxuVjjO8cWWLto1M=; b=Rr2GAhDCbOGBbWO8cyd5NMavdzDWu3R35p5azx1xR9Fyi7MxAVBCRP0lAe05aB0nCR +1PHcae7OOR7eVK2YKpQehlJb3yxe/QPcHjFhS/eDysfGiCnt97Uc3Ni6ySMRZcDCRKU /hRgBhEhNhfVnkX0lQdGC390WuTtuRSE1S12+A9gdd3Yr2pMX93wfY64FJt/t/dphwaj 9fQh5RQdUwT2wV0K+6xlGzbVQola0JZXDqVogSkXeeXhqOBlwk2JkoIpjPcL4nYRWXIJ f2UE0euQbVGz6sq+s8uLkKExdrWGOf+ALGuCjKsrGhzO9Rd05ItBUvazzR27pT2KXsB8 m6pA== X-Gm-Message-State: APjAAAWAmuINiyCkezU8qIIOfKQqr1gXUsHbEBa7UgleNgNtluUTifF+ EBbRfcBvpFmd5HYsCM6Y22dh9Icg X-Google-Smtp-Source: APXvYqzlOf97SIdyCWfq4i8DocVLuvE1TxnRelPzHPEb4X+EzKgatGMYWTkeumVDIwoykWnzKOt4uA== X-Received: by 2002:a05:600c:291d:: with SMTP id i29mr486392wmd.39.1579825270969; Thu, 23 Jan 2020 16:21:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u7sm4617041wmj.3.2020.01.23.16.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:10 -0800 (PST) Message-Id: <9d19794dfd667b3f9752f0e8118dc9eb0c8f59f1.1579825267.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:03 +0000 Subject: [PATCH v4 3/6] t1300: create custom config file without special characters Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers Tests that required a custom configuration file to be created previously used a file with non-alphanumeric characters including escaped double quotes. This is not really necessary for the majority of tests involving custom config files, and decreases test coverage on systems that dissallow such filenames (Windows, etc.). Create two files, one appropriate for testing quoting and one appropriate for general use. Signed-off-by: Matthew Rogers --- t/t1300-config.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index e8b4575758..e5fb9114f6 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1710,18 +1710,23 @@ test_expect_success '--show-origin getting a single key' ' ' test_expect_success 'set up custom config file' ' - CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" && + CUSTOM_CONFIG_FILE="custom.conf" && cat >"$CUSTOM_CONFIG_FILE" <<-\EOF [user] custom = true EOF ' +test_expect_success !MINGW 'set up custom config file with special name characters' ' + WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" && + cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE" +' + test_expect_success !MINGW '--show-origin escape special file name characters' ' cat >expect <<-\EOF && file:"file\" (dq) and spaces.conf" user.custom=true EOF - git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output && + git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output && test_cmp expect output ' @@ -1747,7 +1752,7 @@ test_expect_success '--show-origin stdin with file include' ' test_cmp expect output ' -test_expect_success !MINGW '--show-origin blob' ' +test_expect_success '--show-origin blob' ' blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && cat >expect <<-EOF && blob:$blob user.custom=true @@ -1756,9 +1761,9 @@ test_expect_success !MINGW '--show-origin blob' ' test_cmp expect output ' -test_expect_success !MINGW '--show-origin blob ref' ' +test_expect_success '--show-origin blob ref' ' cat >expect <<-\EOF && - blob:"master:file\" (dq) and spaces.conf" user.custom=true + blob:master:custom.conf user.custom=true EOF git add "$CUSTOM_CONFIG_FILE" && git commit -m "new config file" && From patchwork Fri Jan 24 00:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DCDF17EA for ; Fri, 24 Jan 2020 00:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2966821835 for ; Fri, 24 Jan 2020 00:21:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P+1Hu+s6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729829AbgAXAVQ (ORCPT ); Thu, 23 Jan 2020 19:21:16 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36721 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgAXAVO (ORCPT ); Thu, 23 Jan 2020 19:21:14 -0500 Received: by mail-wr1-f65.google.com with SMTP id z3so24151wru.3 for ; Thu, 23 Jan 2020 16:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=6NRzuQmbNQuX3qumUbsbslbMePVYQw4AO29iqnS59bU=; b=P+1Hu+s6bA2i3ZmYC3kX/68lIsTdkE2x4KMeAEigBjsqwUbtY6tvr475ntOyyEB2oL E7fWX3cXDi8PVJ1Az/dmnI/bnHrnZSsj8sAq/7q0O6O/szWMRO2x/WRqXfPhKVxKSyXb XSK2WOAddj+cqJzIkR+f8kP6wL7nyqFdgLAm15GDCkaG7QD3sVn/5bfeocfrlsEdH0ms 2HPwAj+qT2Sk66bVbGYHtptdSZezOwf8sflPHEClofMlaWZB5c/mK7VCsUGYej0OFSou 0BIofEGfvDSHydRO30mZkC67REdKwSeyv74k3kwnRGxkeh1nQMiNcC7GdnOvLXcf716d gITw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=6NRzuQmbNQuX3qumUbsbslbMePVYQw4AO29iqnS59bU=; b=NL2/AxgG1HLOImjrwsaFsugoyTHo9/FgovL6Q2lJgLxL5f+rw3usC6H0iZ7VITy9Bt N17RFbb3vEEbidQdIgC6YAjxsxUpU1IAJ4YaVsRAfvr1p+5RyZiGXHJwavEcrw65swvi +qLh0qKYqTolFAbhogSbfm2wK/mn+GRL/7TruW6QUT8Eg+wtSHgwPAtDWZDXlEQy0JbH 39bDWeannX4Jo2mHbpzVvFsHyM7eSs7ZCqqwZcqfzbqx2Cv+LYPglINoqhB+1frZHLIz uamndoWO9o6CyfEYe+xpgz/tyDdtneOLoyEFTz9PYHtzywNrnMdTKLB6mHQoTvhwDDNc y8Cg== X-Gm-Message-State: APjAAAX1Ymb8gMq0xmlgNZ/uHjbTWaRlxZk26UH18h1Ql+whWNbDVhJG xUqkYccm5Ev3/D02JQnwsR5r2zWQ X-Google-Smtp-Source: APXvYqyRpKhPuqaDZ+ZO8y9Wk8pRkQao0P2Ci/1PoaiFGB5TcrD6DWiWa7HLeoo2UEyXQOJKm35UOg== X-Received: by 2002:a05:6000:1248:: with SMTP id j8mr702327wrx.44.1579825271718; Thu, 23 Jan 2020 16:21:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x17sm4993461wrt.74.2020.01.23.16.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:11 -0800 (PST) Message-Id: <9f160e281a984ea7578f8fbe244adc77c6585e44.1579825267.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:04 +0000 Subject: [PATCH v4 4/6] config: split repo scope to local and worktree Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers Previously when iterating through git config variables, worktree config and local config were both considered "CONFIG_SCOPE_REPO". This was never a problem before as no one had needed to differentiate between the two cases, but future functionality may care whether or not the config options come from a worktree or from the repository's actual local config file. For example, the planned feature to add a '--show-scope' to config to allow a user to see which scope listed config options come from would confuse users if it just printed 'repo' rather than 'local' or 'worktree' as the documentation would lead them to expect. As well as the additional benefit of making the implementation look more like how the documentation describes the interface. To accomplish this we split out what was previously considered repo scope to be local and worktree. The clients of 'current_config_scope()' who cared about CONFIG_SCOPE_REPO are also modified to similarly care about CONFIG_SCOPE_WORKTREE and CONFIG_SCOPE_LOCAL to preserve previous behavior. Signed-off-by: Matthew Rogers --- config.c | 7 ++----- config.h | 3 ++- remote.c | 3 ++- t/helper/test-config.c | 4 +++- t/t1308-config-set.sh | 2 +- upload-pack.c | 3 ++- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/config.c b/config.c index d75f88ca0c..447a013a15 100644 --- a/config.c +++ b/config.c @@ -1724,15 +1724,12 @@ static int do_git_config_sequence(const struct config_options *opts, if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK)) ret += git_config_from_file(fn, user_config, data); - current_parsing_scope = CONFIG_SCOPE_REPO; + current_parsing_scope = CONFIG_SCOPE_LOCAL; if (!opts->ignore_repo && repo_config && !access_or_die(repo_config, R_OK, 0)) ret += git_config_from_file(fn, repo_config, data); - /* - * Note: this should have a new scope, CONFIG_SCOPE_WORKTREE. - * But let's not complicate things before it's actually needed. - */ + current_parsing_scope = CONFIG_SCOPE_WORKTREE; if (!opts->ignore_worktree && repository_format_worktree_config) { char *path = git_pathdup("config.worktree"); if (!access_or_die(path, R_OK, 0)) diff --git a/config.h b/config.h index 91fd4c5e96..284d92fb0e 100644 --- a/config.h +++ b/config.h @@ -298,7 +298,8 @@ enum config_scope { CONFIG_SCOPE_UNKNOWN = 0, CONFIG_SCOPE_SYSTEM, CONFIG_SCOPE_GLOBAL, - CONFIG_SCOPE_REPO, + CONFIG_SCOPE_LOCAL, + CONFIG_SCOPE_WORKTREE, CONFIG_SCOPE_CMDLINE, }; diff --git a/remote.c b/remote.c index 5c4666b53a..593ce297ed 100644 --- a/remote.c +++ b/remote.c @@ -369,7 +369,8 @@ static int handle_config(const char *key, const char *value, void *cb) } remote = make_remote(name, namelen); remote->origin = REMOTE_CONFIG; - if (current_config_scope() == CONFIG_SCOPE_REPO) + if (current_config_scope() == CONFIG_SCOPE_LOCAL || + current_config_scope() == CONFIG_SCOPE_WORKTREE) remote->configured_in_repo = 1; if (!strcmp(subkey, "mirror")) remote->mirror = git_config_bool(key, value); diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 214003d5b2..6695e463eb 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -44,8 +44,10 @@ static const char *scope_name(enum config_scope scope) return "system"; case CONFIG_SCOPE_GLOBAL: return "global"; - case CONFIG_SCOPE_REPO: + case CONFIG_SCOPE_LOCAL: return "repo"; + case CONFIG_SCOPE_WORKTREE: + return "worktree"; case CONFIG_SCOPE_CMDLINE: return "cmdline"; default: diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index 7b4e1a63eb..90196e2862 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -259,7 +259,7 @@ test_expect_success 'iteration shows correct origins' ' value=from-repo origin=file name=.git/config - scope=repo + scope=local key=foo.bar value=from-cmdline diff --git a/upload-pack.c b/upload-pack.c index a00d7ece6b..c53249cac1 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1073,7 +1073,8 @@ static int upload_pack_config(const char *var, const char *value, void *unused) precomposed_unicode = git_config_bool(var, value); } - if (current_config_scope() != CONFIG_SCOPE_REPO) { + if (current_config_scope() != CONFIG_SCOPE_LOCAL && + current_config_scope() != CONFIG_SCOPE_WORKTREE) { if (!strcmp("uploadpack.packobjectshook", var)) return git_config_string(&pack_objects_hook, var, value); } From patchwork Fri Jan 24 00:21:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9064184C for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A2442071E for ; Fri, 24 Jan 2020 00:21:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mr5L1WR0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729817AbgAXAVP (ORCPT ); Thu, 23 Jan 2020 19:21:15 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33688 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbgAXAVO (ORCPT ); Thu, 23 Jan 2020 19:21:14 -0500 Received: by mail-wr1-f68.google.com with SMTP id b6so36742wrq.0 for ; Thu, 23 Jan 2020 16:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ksmdrg4a3go4/QbgWJ1+2IjATWUvrCDTye6IPw1qD4g=; b=mr5L1WR0c5hhrFBYbE5dwOlPWm0PsZkeJsEkxA76u1nxyulCxuRdzSRhGbfOvnng7W g3+Vmt802BZJxrRZMrB2zwHuQqs5qdx2v64kM2DS/xd0ksBEt9QATd6yuQdmSewcMldv qlobd/wl9YLaBWLTBl6oalJpd+aSxozRgdPj4UyEu6KdsMrQgERu+rxyvotq4svEWfzb X+9S1Z3cBY4LIhZpPnQMRJGy5KTMfmaXyD+OKvMibk2OM2aN9EtLzRhCJL3b5Ix84Bl4 flKVK/GW6+dXUrjBe03+D5AcgJXj4Ni26BguvFxDiEHCEFyPgnpXXXzb2QQKP+L3+Ghc QaYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ksmdrg4a3go4/QbgWJ1+2IjATWUvrCDTye6IPw1qD4g=; b=i7124yp4da2V2hL7hCMNzUaeRcBfXU+oaDC+Rorhcf0jMHSgbKCo9djCOGuunoSZn9 7pWRKLseZ6ld42F5+E/fvR5naQh5dVioPuEHavSGIMmqZ8hpKQw49JvXVPZ+1lH22STW bi3UrRlHRWUdAf9CGu+rdJqEGKtH6Os6DvEqY7ku9lru4QUi90643M2VUw94KdIXWFLY uYcy0Zn6vv6rap4y3eaduKVE+ufWKtqrgKP9PioBewlQxQhUkoB47OJ9Z2JCcdt+wQHJ /0CDrGwH2F+aRwBv5PyH/JGEH+JzG6nGeG14QKfrYPH6Nla5ceHfZxXKyGwDSnT/536i ETZw== X-Gm-Message-State: APjAAAXjTVgq8tg4WRDObPC+fCWXST0EgfLWuLzzqK5Kcm3Xm6BmMTuO Y8jObkw+u0CM1xTOIMOr3rHGNdh7 X-Google-Smtp-Source: APXvYqwFIhWD5SBt0Lqg7kd8nu2hF+CDDFqazrzzVq/mn6oMiBq2v6TtEBbQeqVpDH0zRvOSvkCWZA== X-Received: by 2002:a5d:50ce:: with SMTP id f14mr789371wrt.254.1579825272484; Thu, 23 Jan 2020 16:21:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a14sm5664026wrx.81.2020.01.23.16.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:12 -0800 (PST) Message-Id: <7f00f8559d4e1c4d73bdff9136b03bdd8a53e9dd.1579825267.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:05 +0000 Subject: [PATCH v4 5/6] config: clarify meaning of command line scoping Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers CONFIG_SCOPE_CMDLINE is generally used in the code to refer to config values passed in via the -c option. Options passed in using this mechanism share similar scoping characteristics with the --file and --blob options of the 'config' command, namely that they are only in use for that single invocation of git, and that they supersede the normal system/global/local hierarchy. This patch introduces CONFIG_SCOPE_COMMAND to reflect this new idea, which also makes CONFIG_SCOPE_CMDLINE redundant. Signed-off-by: Matthew Rogers --- config.c | 2 +- config.h | 2 +- t/helper/test-config.c | 4 ++-- t/t1308-config-set.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index 447a013a15..f319a3d6a0 100644 --- a/config.c +++ b/config.c @@ -1737,7 +1737,7 @@ static int do_git_config_sequence(const struct config_options *opts, free(path); } - current_parsing_scope = CONFIG_SCOPE_CMDLINE; + current_parsing_scope = CONFIG_SCOPE_COMMAND; if (!opts->ignore_cmdline && git_config_from_parameters(fn, data) < 0) die(_("unable to parse command-line config")); diff --git a/config.h b/config.h index 284d92fb0e..f383a71404 100644 --- a/config.h +++ b/config.h @@ -300,7 +300,7 @@ enum config_scope { CONFIG_SCOPE_GLOBAL, CONFIG_SCOPE_LOCAL, CONFIG_SCOPE_WORKTREE, - CONFIG_SCOPE_CMDLINE, + CONFIG_SCOPE_COMMAND, }; enum config_scope current_config_scope(void); diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 6695e463eb..78bbb9eb98 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -48,8 +48,8 @@ static const char *scope_name(enum config_scope scope) return "repo"; case CONFIG_SCOPE_WORKTREE: return "worktree"; - case CONFIG_SCOPE_CMDLINE: - return "cmdline"; + case CONFIG_SCOPE_COMMAND: + return "command"; default: return "unknown"; } diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index 90196e2862..fba0abe429 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -265,7 +265,7 @@ test_expect_success 'iteration shows correct origins' ' value=from-cmdline origin=command line name= - scope=cmdline + scope=command EOF GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual && test_cmp expect actual From patchwork Fri Jan 24 00:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11349415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A36B109A for ; Fri, 24 Jan 2020 00:21:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D34121835 for ; Fri, 24 Jan 2020 00:21:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vHQ6tNlg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729832AbgAXAVT (ORCPT ); Thu, 23 Jan 2020 19:21:19 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33832 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729690AbgAXAVP (ORCPT ); Thu, 23 Jan 2020 19:21:15 -0500 Received: by mail-wr1-f66.google.com with SMTP id t2so32923wrr.1 for ; Thu, 23 Jan 2020 16:21:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=LFp4mK6etq2pl4vtqJtV6izsCj/YQsTWJa7JfMKFvKY=; b=vHQ6tNlganZeWWNxdfMppqX3rCv7Ry6xpay+Oh4Jkn4+G6HgiN4rPON6nc/TzmQ4CE KCFhFTZ1X8xizkcjv6ZpRaU7Ponc8BUUYS8eJ4lJVykZbvgCe1SKNKIAlVdwE8OLkYYM c7aboMtw5CzsW+tsDc02fiyDnviqCTibtk2y52QbmjaEeJCqkfZLC5ITXCh8py0+wLVE q8sqBEkU2/dwBqY3iaoqHRv/HbVVxj+uVaFUZo3c8PXMhUmWx92bz3mRSCOgccdKRLr0 IuKw9S+XrRj8YYFTjshmSnDc0HIW4cvEDUF8k8E+CfEhZoGL91fdNXt0DZPOdXkWgbpu opOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=LFp4mK6etq2pl4vtqJtV6izsCj/YQsTWJa7JfMKFvKY=; b=YrJXaifufBdQ8QBIGvQk8szEP6iwB8jUec6M081pai2vSg1nYewx29IcpSz6NGzBpm trv2yJ0Mr959PippC9mZTFkRkywVSTNjjdC1A8Xl5Bl/BhNijWqrwMAwl/LnZHfYGPV6 3s0rtBSTjq991FR+y3RFt7zVJIuKA6zH75IGAAAW8LgC5cVUjXx3FH8MFEldST/7hAwB 79dwegny8Mn+Ht/IiuwbC9dEvpuu27hkI5QdXUTZ22ct3mPQ+nKVd8xMM61RFvw76Bcv e6j+T6pv8X5XsghrlaJvHtLy6eNrNphavw92RsDIxU9jeOzGMLrUn/D5lG+qeEvPAJ8c +hNA== X-Gm-Message-State: APjAAAUx+rNtQslBeH3nGTqFwwsaZyz0A4w/+krodmft+FuMKl/Y1GHE s5UzqrKAziMZnCTUfhUaO/KeeSzv X-Google-Smtp-Source: APXvYqwmKyAIKbA48/XnxWGHbbZeL4CegXPgHRcJsMyx+k/1/yWIbUdZk1peKpjH357ckB1UrBNxvQ== X-Received: by 2002:a5d:44ca:: with SMTP id z10mr744511wrr.266.1579825273333; Thu, 23 Jan 2020 16:21:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b128sm4607798wmb.25.2020.01.23.16.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 16:21:12 -0800 (PST) Message-Id: <5549db7e39bf38aa5cc42292421f4676e3073b7d.1579825267.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Matthew Rogers via GitGitGadget" Date: Fri, 24 Jan 2020 00:21:06 +0000 Subject: [PATCH v4 6/6] config: add '--show-scope' to print the scope of a config value Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matthew Rogers , Matthew Rogers Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matthew Rogers When a user queries config values with --show-origin, often it's difficult to determine what the actual "scope" (local, global, etc.) of a given value is based on just the origin file. Teach 'git config' the '--show-scope' option to print the scope of all displayed config values. Note that we should never see anything of "submodule" scope as that is only ever used by submodule-config.c when parsing the '.gitmodules' file. Signed-off-by: Matthew Rogers --- Documentation/git-config.txt | 15 ++++++--- builtin/config.c | 36 +++++++++++++++++++--- config.c | 26 +++++++++++++++- config.h | 21 +++++++------ submodule-config.c | 4 ++- t/helper/test-config.c | 19 +----------- t/t1300-config.sh | 59 ++++++++++++++++++++++++++++++++++++ 7 files changed, 141 insertions(+), 39 deletions(-) diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 899e92a1c9..2e47765aab 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -9,18 +9,18 @@ git-config - Get and set repository or global options SYNOPSIS -------- [verse] -'git config' [] [--type=] [--show-origin] [-z|--null] name [value [value_regex]] +'git config' [] [--type=] [--show-origin] [--show-scope] [-z|--null] name [value [value_regex]] 'git config' [] [--type=] --add name value 'git config' [] [--type=] --replace-all name value [value_regex] -'git config' [] [--type=] [--show-origin] [-z|--null] --get name [value_regex] -'git config' [] [--type=] [--show-origin] [-z|--null] --get-all name [value_regex] -'git config' [] [--type=] [--show-origin] [-z|--null] [--name-only] --get-regexp name_regex [value_regex] +'git config' [] [--type=] [--show-origin] [--show-scope] [-z|--null] --get name [value_regex] +'git config' [] [--type=] [--show-origin] [--show-scope] [-z|--null] --get-all name [value_regex] +'git config' [] [--type=] [--show-origin] [--show-scope] [-z|--null] [--name-only] --get-regexp name_regex [value_regex] 'git config' [] [--type=] [-z|--null] --get-urlmatch name URL 'git config' [] --unset name [value_regex] 'git config' [] --unset-all name [value_regex] 'git config' [] --rename-section old_name new_name 'git config' [] --remove-section name -'git config' [] [--show-origin] [-z|--null] [--name-only] -l | --list +'git config' [] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list 'git config' [] --get-color name [default] 'git config' [] --get-colorbool name [stdout-is-tty] 'git config' [] -e | --edit @@ -222,6 +222,11 @@ Valid ``'s include: the actual origin (config file path, ref, or blob id if applicable). +--show-scope:: + Similar to `--show-origin` in that it augments the output of + all queried config options with the scope of that value + (local, global, system, command). + --get-colorbool name [stdout-is-tty]:: Find the color setting for `name` (e.g. `color.diff`) and output diff --git a/builtin/config.c b/builtin/config.c index 52a904cfb1..66d2b0d2df 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -33,6 +33,7 @@ static int end_nul; static int respect_includes_opt = -1; static struct config_options config_options; static int show_origin; +static int show_scope; #define ACTION_GET (1<<0) #define ACTION_GET_ALL (1<<1) @@ -155,6 +156,7 @@ static struct option builtin_config_options[] = { OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")), OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")), OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")), + OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")), OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")), OPT_END(), }; @@ -189,11 +191,23 @@ static void show_config_origin(struct strbuf *buf) strbuf_addch(buf, term); } +static void show_config_scope(struct strbuf *buf) +{ + const char term = end_nul ? '\0' : '\t'; + const char *scope = scope_to_string(current_config_scope()); + + strbuf_addstr(buf, N_(scope)); + strbuf_addch(buf, term); +} + static int show_all_config(const char *key_, const char *value_, void *cb) { - if (show_origin) { + if (show_origin || show_scope) { struct strbuf buf = STRBUF_INIT; - show_config_origin(&buf); + if (show_scope) + show_config_scope(&buf); + if (show_origin) + show_config_origin(&buf); /* Use fwrite as "buf" can contain \0's if "end_null" is set. */ fwrite(buf.buf, 1, buf.len, stdout); strbuf_release(&buf); @@ -213,6 +227,8 @@ struct strbuf_list { static int format_config(struct strbuf *buf, const char *key_, const char *value_) { + if (show_scope) + show_config_scope(buf); if (show_origin) show_config_origin(buf); if (show_keys) @@ -622,6 +638,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) !strcmp(given_config_source.file, "-")) { given_config_source.file = NULL; given_config_source.use_stdin = 1; + given_config_source.scope = CONFIG_SCOPE_COMMAND; } if (use_global_config) { @@ -637,6 +654,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) */ die(_("$HOME not set")); + given_config_source.scope = CONFIG_SCOPE_GLOBAL; + if (access_or_warn(user_config, R_OK, 0) && xdg_config && !access_or_warn(xdg_config, R_OK, 0)) { given_config_source.file = xdg_config; @@ -646,11 +665,13 @@ int cmd_config(int argc, const char **argv, const char *prefix) free(xdg_config); } } - else if (use_system_config) + else if (use_system_config) { given_config_source.file = git_etc_gitconfig(); - else if (use_local_config) + given_config_source.scope = CONFIG_SCOPE_SYSTEM; + } else if (use_local_config) { given_config_source.file = git_pathdup("config"); - else if (use_worktree_config) { + given_config_source.scope = CONFIG_SCOPE_LOCAL; + } else if (use_worktree_config) { struct worktree **worktrees = get_worktrees(0); if (repository_format_worktree_config) given_config_source.file = git_pathdup("config.worktree"); @@ -662,13 +683,18 @@ int cmd_config(int argc, const char **argv, const char *prefix) "section in \"git help worktree\" for details")); else given_config_source.file = git_pathdup("config"); + given_config_source.scope = CONFIG_SCOPE_LOCAL; free_worktrees(worktrees); } else if (given_config_source.file) { if (!is_absolute_path(given_config_source.file) && prefix) given_config_source.file = prefix_filename(prefix, given_config_source.file); + given_config_source.scope = CONFIG_SCOPE_COMMAND; + } else if (given_config_source.blob) { + given_config_source.scope = CONFIG_SCOPE_COMMAND; } + if (respect_includes_opt == -1) config_options.respect_includes = !given_config_source.file; else diff --git a/config.c b/config.c index f319a3d6a0..469dff57b4 100644 --- a/config.c +++ b/config.c @@ -1702,6 +1702,7 @@ static int do_git_config_sequence(const struct config_options *opts, char *xdg_config = xdg_config_home("config"); char *user_config = expand_user_path("~/.gitconfig", 0); char *repo_config; + enum config_scope prev_parsing_scope = current_parsing_scope; if (opts->commondir) repo_config = mkpathdup("%s/config", opts->commondir); @@ -1741,7 +1742,7 @@ static int do_git_config_sequence(const struct config_options *opts, if (!opts->ignore_cmdline && git_config_from_parameters(fn, data) < 0) die(_("unable to parse command-line config")); - current_parsing_scope = CONFIG_SCOPE_UNKNOWN; + current_parsing_scope = prev_parsing_scope; free(xdg_config); free(user_config); free(repo_config); @@ -1762,6 +1763,9 @@ int config_with_options(config_fn_t fn, void *data, data = &inc; } + if (config_source) + current_parsing_scope = config_source->scope; + /* * If we have a specific filename, use it. Otherwise, follow the * regular lookup sequence. @@ -3294,6 +3298,26 @@ const char *current_config_origin_type(void) } } +const char *scope_to_string(enum config_scope scope) +{ + switch (scope) { + case CONFIG_SCOPE_SYSTEM: + return "system"; + case CONFIG_SCOPE_GLOBAL: + return "global"; + case CONFIG_SCOPE_LOCAL: + return "local"; + case CONFIG_SCOPE_WORKTREE: + return "worktree"; + case CONFIG_SCOPE_COMMAND: + return "command"; + case CONFIG_SCOPE_SUBMODULE: + return "submodule"; + default: + return "unknown"; + } +} + const char *current_config_name(void) { const char *name; diff --git a/config.h b/config.h index f383a71404..7b3aec0092 100644 --- a/config.h +++ b/config.h @@ -35,10 +35,22 @@ struct object_id; #define CONFIG_REGEX_NONE ((void *)1) +enum config_scope { + CONFIG_SCOPE_UNKNOWN = 0, + CONFIG_SCOPE_SYSTEM, + CONFIG_SCOPE_GLOBAL, + CONFIG_SCOPE_LOCAL, + CONFIG_SCOPE_WORKTREE, + CONFIG_SCOPE_COMMAND, + CONFIG_SCOPE_SUBMODULE, +}; +const char *scope_to_string(enum config_scope scope); + struct git_config_source { unsigned int use_stdin:1; const char *file; const char *blob; + enum config_scope scope; }; enum config_origin_type { @@ -294,15 +306,6 @@ int config_error_nonbool(const char *); int git_config_parse_parameter(const char *, config_fn_t fn, void *data); -enum config_scope { - CONFIG_SCOPE_UNKNOWN = 0, - CONFIG_SCOPE_SYSTEM, - CONFIG_SCOPE_GLOBAL, - CONFIG_SCOPE_LOCAL, - CONFIG_SCOPE_WORKTREE, - CONFIG_SCOPE_COMMAND, -}; - enum config_scope current_config_scope(void); const char *current_config_origin_type(void); const char *current_config_name(void); diff --git a/submodule-config.c b/submodule-config.c index 85064810b2..b8e97d8ae8 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -635,7 +635,9 @@ static void submodule_cache_check_init(struct repository *repo) static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data) { if (repo->worktree) { - struct git_config_source config_source = { 0 }; + struct git_config_source config_source = { + 0, .scope = CONFIG_SCOPE_SUBMODULE + }; const struct config_options opts = { 0 }; struct object_id oid; char *file; diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 78bbb9eb98..2e91879b2a 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -37,23 +37,6 @@ * */ -static const char *scope_name(enum config_scope scope) -{ - switch (scope) { - case CONFIG_SCOPE_SYSTEM: - return "system"; - case CONFIG_SCOPE_GLOBAL: - return "global"; - case CONFIG_SCOPE_LOCAL: - return "repo"; - case CONFIG_SCOPE_WORKTREE: - return "worktree"; - case CONFIG_SCOPE_COMMAND: - return "command"; - default: - return "unknown"; - } -} static int iterate_cb(const char *var, const char *value, void *data) { static int nr; @@ -65,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data) printf("value=%s\n", value ? value : "(null)"); printf("origin=%s\n", current_config_origin_type()); printf("name=%s\n", current_config_name()); - printf("scope=%s\n", scope_name(current_config_scope())); + printf("scope=%s\n", scope_to_string(current_config_scope())); return 0; } diff --git a/t/t1300-config.sh b/t/t1300-config.sh index e5fb9114f6..79dbea9bd1 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1771,6 +1771,65 @@ test_expect_success '--show-origin blob ref' ' test_cmp expect output ' +test_expect_success '--show-scope with --list' ' + cat >expect <<-EOF && + global user.global=true + global user.override=global + global include.path=$INCLUDE_DIR/absolute.include + global user.absolute=include + local user.local=true + local user.override=local + local include.path=../include/relative.include + local user.relative=include + command user.cmdline=true + EOF + git -c user.cmdline=true config --list --show-scope >output && + test_cmp expect output +' + +test_expect_success !MINGW '--show-scope with --blob' ' + blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && + cat >expect <<-EOF && + command user.custom=true + EOF + git config --blob=$blob --show-scope --list >output && + test_cmp expect output +' + +test_expect_success '--show-scope with --local' ' + cat >expect <<-\EOF && + local user.local=true + local user.override=local + local include.path=../include/relative.include + EOF + git config --local --list --show-scope >output && + test_cmp expect output +' + +test_expect_success '--show-scope getting a single value' ' + cat >expect <<-\EOF && + local true + EOF + git config --show-scope --get user.local >output && + test_cmp expect output +' + +test_expect_success '--show-scope with --show-origin' ' + cat >expect <<-EOF && + global file:$HOME/.gitconfig user.global=true + global file:$HOME/.gitconfig user.override=global + global file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include + global file:$INCLUDE_DIR/absolute.include user.absolute=include + local file:.git/config user.local=true + local file:.git/config user.override=local + local file:.git/config include.path=../include/relative.include + local file:.git/../include/relative.include user.relative=include + command command line: user.cmdline=true + EOF + git -c user.cmdline=true config --list --show-origin --show-scope >output && + test_cmp expect output +' + test_expect_success '--local requires a repo' ' # we expect 128 to ensure that we do not simply # fail to find anything and return code "1"