From patchwork Mon Oct 4 01:58:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12533187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FA87C433EF for ; Mon, 4 Oct 2021 01:58:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D66F6120D for ; Mon, 4 Oct 2021 01:58:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbhJDCAS (ORCPT ); Sun, 3 Oct 2021 22:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232131AbhJDCAR (ORCPT ); Sun, 3 Oct 2021 22:00:17 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC96AC0613EC for ; Sun, 3 Oct 2021 18:58:28 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id e12so7553403wra.4 for ; Sun, 03 Oct 2021 18:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iORiwJkQL/Bn3ihbf/5+8i9O5gI0zqwCTqo4pq0kyHY=; b=TdNNVxjkp+vN3sZwATxc1PRgPeusTcBuOv8cNPwCV71cRC/rcH2cRB+78sbPMG9Qhp kwTLenOSGHS3HyuHF8SEmFU4cyD7s95m1sDKhlLc2STSjwXPFf1NYl1YlxTunqAbM2US zTkje8OJwkNl6btMw/JONB/NLHLjhQCrvNOK9NPACP7mlj93Cb8XC8D7T8/XnS9rt0xh rDK+9c/lqC6D+IbBuMHhJIokqktog122NPJHuR8OMPgGKwhjy0IIKFZHDuU/i/PAKmAj Z5pcHqW0VzsOZ+HAoQ/RTSv4odknQHbeqexM7F7jDPVm94vZvVqcVh19ylOz3W4KhQOh VnsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iORiwJkQL/Bn3ihbf/5+8i9O5gI0zqwCTqo4pq0kyHY=; b=6LAjwBH5WpPN1DuwYAaPOzo3K4fRphlWSrzu3SkSkpFOLiX54bt9GsGsuHoyDqnIXV cfcPqUAj8gxltWpTfCxDpoBhAngM5wJIKQaog2Hj3j0u2xOBWQoV8yEnsjRNfPioMTQ5 jMuuQD8Am+xcOQYn/oZPAKACxPDn1GUKEPYPALitqKbdL4yT2oWxuOBLHVxZ67F75qYf q4QJAjjbbAg8+G5i4eir7l41pHCJe9396p/gz3O8GdUdIw0yIUUuP3PULCd+iQloEpT0 4WtmRTGrgHncHd9hhCzjPyi7PAm+P9eHJRByMXkHYIpdAyDr53/7mbS5gBQnFfYWpZxX a2GQ== X-Gm-Message-State: AOAM530pOuT0tjbwhKqwJzQZb2WzR9zd/5DROiyYBBlTxCFtoNAhtZa3 MbKyD1aUP74WIQ722EwtPJZXu8ftm/bmNQ== X-Google-Smtp-Source: ABdhPJwowsuFMo3ts2/e0e1FJ8rp85o1Ni+hq6uNzv0iTFo8lMrG1EjReb7ftT+r3CkZkES99rmMFg== X-Received: by 2002:adf:a152:: with SMTP id r18mr11290972wrr.317.1633312707184; Sun, 03 Oct 2021 18:58:27 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y23sm15349355wmi.16.2021.10.03.18.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 18:58:26 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ben Boeckel , Johannes Schindelin , Heba Waly , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH 1/5] advice.h: don't indent top-level enum Date: Mon, 4 Oct 2021 03:58:20 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1404.g7bcfc82b295 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a style nit introduced in b3b18d16213 (advice: revamp advise API, 2020-03-02) and remove the leading whitespace before "enum". Signed-off-by: Ævar Arnfjörð Bjarmason --- advice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advice.h b/advice.h index 601265fd107..694219f5cb2 100644 --- a/advice.h +++ b/advice.h @@ -12,7 +12,7 @@ struct string_list; * Add the new config variable to Documentation/config/advice.txt. * Call advise_if_enabled to print your advice. */ - enum advice_type { +enum advice_type { ADVICE_ADD_EMBEDDED_REPO, ADVICE_ADD_EMPTY_PATHSPEC, ADVICE_ADD_IGNORED_FILE, From patchwork Mon Oct 4 01:58:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12533185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498B9C433FE for ; Mon, 4 Oct 2021 01:58:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D7F66124C for ; Mon, 4 Oct 2021 01:58:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbhJDCAT (ORCPT ); Sun, 3 Oct 2021 22:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232156AbhJDCAR (ORCPT ); Sun, 3 Oct 2021 22:00:17 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952C6C0613EC for ; Sun, 3 Oct 2021 18:58:29 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id k7so27652917wrd.13 for ; Sun, 03 Oct 2021 18:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BBLtQ7SqIiRBDJWmzxObPdpeRfGhIBYNh5qpoduwBog=; b=NXPio6zb1o87NelylsaYG5OlygE7cXFm4EuEOSLf9XPC7wVBnUrxMv3dF075KxH9eY R85MoqDY83HIlBtqmOKRh75ynXQAA5T+aZnFDjkIpwrAaHSwoDVuC3P+CCf0FsLsflLa msk1rH+WKjh6EpVu4O1gpJ2zlIEm/CBecFnXAs91WpnB2PLgmkkH0Y0w/h0otrcB8djQ Z7N9QuftNSg5t+hlj7GCxTgaZ2dh5hs22fMXk7I2GItqoXAKtOWab9mVo5ujtigJCDWP vZNE0jx+69fVuc0GVdcfkzPlmkWAXhNIBnmXg7lcCp80AL5d+RNelQYJsPjRkXhhgvpd isGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BBLtQ7SqIiRBDJWmzxObPdpeRfGhIBYNh5qpoduwBog=; b=GctRGZfXxqKrpkYMfc/yOxAXTfKKIdY4IT/MX76dWWZtX/5Tg0OhSEJEd3wyqKXjaw KVmhULFhky5SHMovRANoU+SJLhkwqebfGqpsu55sQhDA9yx65FtturpjBrEjecQ5OKqb JZE9S9XIRl+Lv4+BcPm3cRwT6VcLbKkupACGkgUUAqFEpKkcm8LS6RyJ2QS7VMv7IUqh 85V5o3Tz42hyy/jpeulwwm4uQI4EkQRbZEZaPFSxrjX5ST6cJxH9qzdwG1w17KkuTbPY ObkBR/t/352xhVV+GtSlWVDOh6aRrx63MRsZhNEW83P/Zm26pfZDORe5roCnOuLQZ1Rb qKKg== X-Gm-Message-State: AOAM530FLEvdXGewCHgzBWh2aLj2OrrhA9EpHZYcHXFta1bwEq8/Dd9O gcyV+dZWFpMwC4+MSowapfYwgDHRY6rLkg== X-Google-Smtp-Source: ABdhPJxgJAMMLjzvQgtmpOl1c3FzT+azygXUIXvkvhMwyRu47Xe4ooarxrVsU3Xq+uR4YG1ESJzy5g== X-Received: by 2002:a5d:47c4:: with SMTP id o4mr11244703wrc.102.1633312707870; Sun, 03 Oct 2021 18:58:27 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y23sm15349355wmi.16.2021.10.03.18.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 18:58:27 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ben Boeckel , Johannes Schindelin , Heba Waly , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH 2/5] advice output: emit empty lines as "hint:", not "hint: " Date: Mon, 4 Oct 2021 03:58:21 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1404.g7bcfc82b295 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Let's not needlessly add this trailing whitespace to empty "hint:" lines, this makes copy/pasting them better, and also makes the tests more straightforward. Signed-off-by: Ævar Arnfjörð Bjarmason --- advice.c | 9 +++++++-- t/t7004-tag.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/advice.c b/advice.c index 2f5499a5e18..9691c7e7899 100644 --- a/advice.c +++ b/advice.c @@ -90,10 +90,15 @@ static void vadvise(const char *advice, int display_instructions, strbuf_addf(&buf, turn_off_instructions, key); for (cp = buf.buf; *cp; cp = np) { + int len; + np = strchrnul(cp, '\n'); - fprintf(stderr, _("%shint: %.*s%s\n"), + len = np - cp; + + fprintf(stderr, _("%shint:%s%.*s%s\n"), advise_get_color(ADVICE_COLOR_HINT), - (int)(np - cp), cp, + len ? " " : "", + len, cp, advise_get_color(ADVICE_COLOR_RESET)); if (*np) np++; diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 082be85dffc..a7041e64ccf 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1749,10 +1749,10 @@ test_expect_success '--points-at finds annotated tags of tags' ' ' test_expect_success 'recursive tagging should give advice' ' - sed -e "s/|$//" <<-EOF >expect && + cat <<-EOF >expect && hint: You have created a nested tag. The object referred to by your new tag is hint: already a tag. If you meant to tag the object that it points to, use: - hint: | + hint: hint: git tag -f nested annotated-v4.0^{} hint: Disable this message with "git config advice.nestedTag false" EOF From patchwork Mon Oct 4 01:58:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12533189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D1D0C433F5 for ; Mon, 4 Oct 2021 01:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E46C961251 for ; Mon, 4 Oct 2021 01:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbhJDCAU (ORCPT ); Sun, 3 Oct 2021 22:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbhJDCAS (ORCPT ); Sun, 3 Oct 2021 22:00:18 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49722C061781 for ; Sun, 3 Oct 2021 18:58:30 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r7so12299129wrc.10 for ; Sun, 03 Oct 2021 18:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xeI+ChQIs9rABQwn6X5yx+5WsnJVtgEtVV0J/ZHmBL4=; b=MGfSYbIBz+sl2hjdSOj9OTQnfX7VBO8pbWS/xZPI1Y45zyBx8o3+PfsgET4X8Bs0re ETsayFnvrzhSEUJNWcK7gR35rECisxJgtyUCeQx2535b/gXx2vVMDiqTEHV0li77dEft XID8jpsPsml7Wr2p/8Ch0jOVbZkS0zGtu43QRVcVDHfVgbL3K+ZHWsNwl2hp2+a1NKt5 bDhGHkxbAjcjG06oG/mkGvz+DtjytgvBvCWb8Mhugt5WwotXUsvsH1G9IukacuT0yj0j bUdqPBxv0AyjWvMCsREQwns5aXVbG2DZqRB/HPvoOCbPK28Kq9mm3JlpW0BYQDfxYQkH 3VJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xeI+ChQIs9rABQwn6X5yx+5WsnJVtgEtVV0J/ZHmBL4=; b=q8PacU9KjMLXXBqHxz5zRjdPoX/NxofE0mXe7JxCFHc0lsb0GSsJCxmysCPzDcl8aK H4KZ/4c9cZEY4ReZCrnYcHkeGeAzWUcYYGyVhfDj7t+kD3mAs9uTgPFltFPhyfVLaZ27 aAqgITrYLFbsWHp9oewJed9t6r01R+erzih/XMA/xXxUN8FI0VBIabgVZwHX1v/ZFrJW yDKhPgHdS4FneIQrfMlTPvXehij/iY0GsetPE9YXhDT06/7jr+9R8AWQsiGfSiEaKrzV wguYNUXkVIREDwQigTjTfJzaTHwnH0Bt+FHG+hkizQgP0HPyQBlFWBPOVAyAYiBgsFwt a7tQ== X-Gm-Message-State: AOAM5301g/NgpOONPszkFGtwAhudugVI9m4MkAPDAZeikwVYb2NFH/gU 7Z4cAj/4MN0/zjcAewSptyJ3kXU+Atb78g== X-Google-Smtp-Source: ABdhPJxbCepRdVDKYhzGSCfkO1yQVNs1mTRr34s+mRzXcpS7o19IBSriIAeMZ001rNsO0NeO9F8Zug== X-Received: by 2002:adf:9784:: with SMTP id s4mr3608739wrb.277.1633312708694; Sun, 03 Oct 2021 18:58:28 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y23sm15349355wmi.16.2021.10.03.18.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 18:58:28 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ben Boeckel , Johannes Schindelin , Heba Waly , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH 3/5] advice.[ch]: remove advice.pushNonFastForward alias Date: Mon, 4 Oct 2021 03:58:22 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1404.g7bcfc82b295 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The advice.pushNonFastForward variable has been primarily known as advice.pushUpdateRejected since 1184564eac8 (push: rename config variable for more general use, 2012-12-02). It's been long enough by far that we can declare this deprecation period over and remove it. The only downside for users is going to be that they'll potentially see a more verbose warning that they'll have to re-squash by changing their config, but that's hardly an undue burden. Doing this allows us to simplify the advice_enabled() function down to something truly trivial. Change the only in-tree user of this, it was added in fd47d7b94db (git-remote-mediawiki: obey advice.pushNonFastForward, 2011-09-27), and not renamed in 1184564eac8 along with the rest. Signed-off-by: Ævar Arnfjörð Bjarmason --- advice.c | 12 +----------- advice.h | 1 - contrib/mw-to-git/git-remote-mediawiki.perl | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/advice.c b/advice.c index 9691c7e7899..b395bc7d187 100644 --- a/advice.c +++ b/advice.c @@ -52,10 +52,6 @@ static struct { [ADVICE_PUSH_FETCH_FIRST] = { "pushFetchFirst", 1 }, [ADVICE_PUSH_NEEDS_FORCE] = { "pushNeedsForce", 1 }, [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "pushRefNeedsUpdate", 1 }, - - /* make this an alias for backward compatibility */ - [ADVICE_PUSH_UPDATE_REJECTED_ALIAS] = { "pushNonFastForward", 1 }, - [ADVICE_PUSH_NON_FF_CURRENT] = { "pushNonFFCurrent", 1 }, [ADVICE_PUSH_NON_FF_MATCHING] = { "pushNonFFMatching", 1 }, [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "pushUnqualifiedRefName", 1 }, @@ -116,13 +112,7 @@ void advise(const char *advice, ...) int advice_enabled(enum advice_type type) { - switch(type) { - case ADVICE_PUSH_UPDATE_REJECTED: - return advice_setting[ADVICE_PUSH_UPDATE_REJECTED].enabled && - advice_setting[ADVICE_PUSH_UPDATE_REJECTED_ALIAS].enabled; - default: - return advice_setting[type].enabled; - } + return advice_setting[type].enabled; } void advise_if_enabled(enum advice_type type, const char *advice, ...) diff --git a/advice.h b/advice.h index 694219f5cb2..ab25c6ba9a0 100644 --- a/advice.h +++ b/advice.h @@ -32,7 +32,6 @@ enum advice_type { ADVICE_PUSH_NON_FF_CURRENT, ADVICE_PUSH_NON_FF_MATCHING, ADVICE_PUSH_UNQUALIFIED_REF_NAME, - ADVICE_PUSH_UPDATE_REJECTED_ALIAS, ADVICE_PUSH_UPDATE_REJECTED, ADVICE_PUSH_REF_NEEDS_UPDATE, ADVICE_RESET_QUIET_WARNING, diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl index a5624413dc1..158e89e5048 100755 --- a/contrib/mw-to-git/git-remote-mediawiki.perl +++ b/contrib/mw-to-git/git-remote-mediawiki.perl @@ -983,7 +983,7 @@ sub mw_import_revids { } sub error_non_fast_forward { - my $advice = run_git_quoted(["config", "--bool", "advice.pushNonFastForward"]); + my $advice = run_git_quoted(["config", "--bool", "advice.pushUpdateRejected"]); chomp($advice); if ($advice ne 'false') { # Native git-push would show this after the summary. From patchwork Mon Oct 4 01:58:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12533191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 138C1C433FE for ; Mon, 4 Oct 2021 01:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 019376120D for ; Mon, 4 Oct 2021 01:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232210AbhJDCAV (ORCPT ); Sun, 3 Oct 2021 22:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbhJDCAT (ORCPT ); Sun, 3 Oct 2021 22:00:19 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25ADBC0613EC for ; Sun, 3 Oct 2021 18:58:31 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m22so22373416wrb.0 for ; Sun, 03 Oct 2021 18:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+/D3A1XDpemrxg+52RCGlQ/4BirZwPqERG6Ya9OYdU0=; b=ANuaq+esNS30v6yT/VPnprUQA2w3LrIsaF0z85+OoA7505A52amj+Ejo1KFVprKM8a Mkg1c6mQD7W3wbvmBbezAWpXho8VfiWEUq5+wBEnZH/83o73iKRY52g+gmwnZ7/u//ll 7gRTBGGiAYhfVIjsT6FfpMBL+Tf1fSw0ua/Wl3ZDzBQ9iuHyQ1IQeC+S7fB3hISM8M3a tR2umptG8P9c3w9r5neZn7/je/1h0TcLi1uuH5bo11Oh2s1f9c86NGsEmpWpz9XjsN4C goXeyzCjYqDgWbZNIK9f44fXHKO0rE69Dqe1R315ul8lt1xrKfs6f0MgL17+KEyF2N8y 3NuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/D3A1XDpemrxg+52RCGlQ/4BirZwPqERG6Ya9OYdU0=; b=wpC9g28v/sR+SgSz1wJcxNF4XwhY1pQinnCVbaNWhj8zdDqdT5CIf3h5K+2Pvhwq5G yyRqk8AqACs+YS12Yan/p+k5YbQibgxXH21oo/LXCYSSQ/cGLwHLFlbOQkW1eBsBmqyz YhZeUVGr9rFe+1H/8yRG0W+8GvySxrCDtk3+AyfRC0O3lrtgRqdHO+Oz2/p1OZChyNJh OpuwtWJA3AWbfHty2jPCiwpnb590M/1LnVlym+zJcbvTteIUzBHYkFZ6Zrz2I73XGbuD x66qF6Y9oIG0x57y+XUHt6l7K/+UW/C8K+6nWioVDhXGkifZM6yx0AdLvc+GVvf+8kas 3WoA== X-Gm-Message-State: AOAM532R1VYwBkz2ZaJU2lKvSPyB983jExO2LbXrx5ajSlRxi+x5VY0i T2xcwGKybZFvDKhErTFrhhL/UnzlstXBOw== X-Google-Smtp-Source: ABdhPJyzj/JU5A3R9bu1lcaG5iZ5XJsPZRxIx6h2u7J3XUGxI8oDBcdl8bU/38VP2dVvWi05pY09zA== X-Received: by 2002:a05:6000:1544:: with SMTP id 4mr11367161wry.370.1633312709574; Sun, 03 Oct 2021 18:58:29 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y23sm15349355wmi.16.2021.10.03.18.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 18:58:29 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ben Boeckel , Johannes Schindelin , Heba Waly , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH 4/5] advice API: revamp the API, again Date: Mon, 4 Oct 2021 03:58:23 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1404.g7bcfc82b295 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Follow-up b3b18d16213 (advice: revamp advise API, 2020-03-02) and revamp the declaration of the advice variables to: * Make it trivial to grep for them, by giving them the "advice." prefix explicitly, which also saves us from stripping it off during config parsing. * All of the advice is enabled by default, so we can do this more succinctly by having a "disabled" slot, instead of "enabled", and then rely on the compiler to implicitly zero out the struct. Signed-off-by: Ævar Arnfjörð Bjarmason --- advice.c | 81 +++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/advice.c b/advice.c index b395bc7d187..f7cedac7549 100644 --- a/advice.c +++ b/advice.c @@ -33,46 +33,46 @@ static const char *advise_get_color(enum color_advice ix) static struct { const char *key; - int enabled; + int disabled; } advice_setting[] = { - [ADVICE_ADD_EMBEDDED_REPO] = { "addEmbeddedRepo", 1 }, - [ADVICE_ADD_EMPTY_PATHSPEC] = { "addEmptyPathspec", 1 }, - [ADVICE_ADD_IGNORED_FILE] = { "addIgnoredFile", 1 }, - [ADVICE_AM_WORK_DIR] = { "amWorkDir", 1 }, - [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] = { "checkoutAmbiguousRemoteBranchName", 1 }, - [ADVICE_COMMIT_BEFORE_MERGE] = { "commitBeforeMerge", 1 }, - [ADVICE_DETACHED_HEAD] = { "detachedHead", 1 }, - [ADVICE_FETCH_SHOW_FORCED_UPDATES] = { "fetchShowForcedUpdates", 1 }, - [ADVICE_GRAFT_FILE_DEPRECATED] = { "graftFileDeprecated", 1 }, - [ADVICE_IGNORED_HOOK] = { "ignoredHook", 1 }, - [ADVICE_IMPLICIT_IDENTITY] = { "implicitIdentity", 1 }, - [ADVICE_NESTED_TAG] = { "nestedTag", 1 }, - [ADVICE_OBJECT_NAME_WARNING] = { "objectNameWarning", 1 }, - [ADVICE_PUSH_ALREADY_EXISTS] = { "pushAlreadyExists", 1 }, - [ADVICE_PUSH_FETCH_FIRST] = { "pushFetchFirst", 1 }, - [ADVICE_PUSH_NEEDS_FORCE] = { "pushNeedsForce", 1 }, - [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "pushRefNeedsUpdate", 1 }, - [ADVICE_PUSH_NON_FF_CURRENT] = { "pushNonFFCurrent", 1 }, - [ADVICE_PUSH_NON_FF_MATCHING] = { "pushNonFFMatching", 1 }, - [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "pushUnqualifiedRefName", 1 }, - [ADVICE_PUSH_UPDATE_REJECTED] = { "pushUpdateRejected", 1 }, - [ADVICE_RESET_QUIET_WARNING] = { "resetQuiet", 1 }, - [ADVICE_RESOLVE_CONFLICT] = { "resolveConflict", 1 }, - [ADVICE_RM_HINTS] = { "rmHints", 1 }, - [ADVICE_SEQUENCER_IN_USE] = { "sequencerInUse", 1 }, - [ADVICE_SET_UPSTREAM_FAILURE] = { "setUpstreamFailure", 1 }, - [ADVICE_SKIPPED_CHERRY_PICKS] = { "skippedCherryPicks", 1 }, - [ADVICE_STATUS_AHEAD_BEHIND_WARNING] = { "statusAheadBehindWarning", 1 }, - [ADVICE_STATUS_HINTS] = { "statusHints", 1 }, - [ADVICE_STATUS_U_OPTION] = { "statusUoption", 1 }, - [ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 }, - [ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 }, - [ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 }, + [ADVICE_ADD_EMBEDDED_REPO] = { "advice.addEmbeddedRepo" }, + [ADVICE_ADD_EMPTY_PATHSPEC] = { "advice.addEmptyPathspec" }, + [ADVICE_ADD_IGNORED_FILE] = { "advice.addIgnoredFile" }, + [ADVICE_AM_WORK_DIR] = { "advice.amWorkDir" }, + [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] = { "advice.checkoutAmbiguousRemoteBranchName" }, + [ADVICE_COMMIT_BEFORE_MERGE] = { "advice.commitBeforeMerge" }, + [ADVICE_DETACHED_HEAD] = { "advice.detachedHead" }, + [ADVICE_FETCH_SHOW_FORCED_UPDATES] = { "advice.fetchShowForcedUpdates" }, + [ADVICE_GRAFT_FILE_DEPRECATED] = { "advice.graftFileDeprecated" }, + [ADVICE_IGNORED_HOOK] = { "advice.ignoredHook" }, + [ADVICE_IMPLICIT_IDENTITY] = { "advice.implicitIdentity" }, + [ADVICE_NESTED_TAG] = { "advice.nestedTag" }, + [ADVICE_OBJECT_NAME_WARNING] = { "advice.objectNameWarning" }, + [ADVICE_PUSH_ALREADY_EXISTS] = { "advice.pushAlreadyExists" }, + [ADVICE_PUSH_FETCH_FIRST] = { "advice.pushFetchFirst" }, + [ADVICE_PUSH_NEEDS_FORCE] = { "advice.pushNeedsForce" }, + [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "advice.pushRefNeedsUpdate" }, + [ADVICE_PUSH_NON_FF_CURRENT] = { "advice.pushNonFFCurrent" }, + [ADVICE_PUSH_NON_FF_MATCHING] = { "advice.pushNonFFMatching" }, + [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "advice.pushUnqualifiedRefName" }, + [ADVICE_PUSH_UPDATE_REJECTED] = { "advice.pushUpdateRejected" }, + [ADVICE_RESET_QUIET_WARNING] = { "advice.resetQuiet" }, + [ADVICE_RESOLVE_CONFLICT] = { "advice.resolveConflict" }, + [ADVICE_RM_HINTS] = { "advice.rmHints" }, + [ADVICE_SEQUENCER_IN_USE] = { "advice.sequencerInUse" }, + [ADVICE_SET_UPSTREAM_FAILURE] = { "advice.setUpstreamFailure" }, + [ADVICE_SKIPPED_CHERRY_PICKS] = { "advice.skippedCherryPicks" }, + [ADVICE_STATUS_AHEAD_BEHIND_WARNING] = { "advice.statusAheadBehindWarning" }, + [ADVICE_STATUS_HINTS] = { "advice.statusHints" }, + [ADVICE_STATUS_U_OPTION] = { "advice.statusUoption" }, + [ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "advice.submoduleAlternateErrorStrategyDie" }, + [ADVICE_UPDATE_SPARSE_PATH] = { "advice.updateSparsePath" }, + [ADVICE_WAITING_FOR_EDITOR] = { "advice.waitingForEditor" }, }; static const char turn_off_instructions[] = N_("\n" - "Disable this message with \"git config advice.%s false\""); + "Disable this message with \"git config %s false\""); static void vadvise(const char *advice, int display_instructions, const char *key, va_list params) @@ -112,7 +112,7 @@ void advise(const char *advice, ...) int advice_enabled(enum advice_type type) { - return advice_setting[type].enabled; + return !advice_setting[type].disabled; } void advise_if_enabled(enum advice_type type, const char *advice, ...) @@ -129,7 +129,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...) int git_default_advice_config(const char *var, const char *value) { - const char *k, *slot_name; + const char *slot_name; int i; if (!strcmp(var, "color.advice")) { @@ -146,13 +146,10 @@ int git_default_advice_config(const char *var, const char *value) return color_parse(value, advice_colors[slot]); } - if (!skip_prefix(var, "advice.", &k)) - return 0; - for (i = 0; i < ARRAY_SIZE(advice_setting); i++) { - if (strcasecmp(k, advice_setting[i].key)) + if (strcasecmp(var, advice_setting[i].key)) continue; - advice_setting[i].enabled = git_config_bool(var, value); + advice_setting[i].disabled = !git_config_bool(var, value); return 0; } From patchwork Mon Oct 4 01:58:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12533193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5B0FC433F5 for ; Mon, 4 Oct 2021 01:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8CEB6124C for ; Mon, 4 Oct 2021 01:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232233AbhJDCAY (ORCPT ); Sun, 3 Oct 2021 22:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232156AbhJDCAU (ORCPT ); Sun, 3 Oct 2021 22:00:20 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C47D0C061781 for ; Sun, 3 Oct 2021 18:58:31 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t8so27868592wri.1 for ; Sun, 03 Oct 2021 18:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QxTEtWaBN/vuEBl0WG4WPjLiWGe+T1qB9CNWeU2zUV4=; b=VOQJH4NqKWMaheS9IN0VibD82WZOcv7HQEtdJ6BEqm9dMbrxPMOMjENNpnsqiBhva+ IiTB5yL1rB1BsIvPlsGR85lCAZcHolSCcToo9spBMDppRl2Re2Mjs+k+cNV1rtCej4dL cXTw2NuW0njgR81Tpaa7GuUBlCMtO0djjY15DC1B3lbCegEVy2N2AC8JfR65waGu0mMC qXbgwiTpekM1WliwVGoDPvjccvdtictjoEWNpc5rEYCtB25CC+YlLoF8CiE43vulmoQv B7VKQ/lOfSc/aHdv17l194YaQee7N5VAzjjT/Zfl2r1EOMapPwO5tnPCHZaqH4vnQgqx TGNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QxTEtWaBN/vuEBl0WG4WPjLiWGe+T1qB9CNWeU2zUV4=; b=noYmkOSzDgMO6eqCM+h3fHfucJJl8EIG0iMm8gcibc0deZ+ok5PToOpMSeUj4jX0ij HfGbUNgh0n9/bSJhyjJYvXuQoBLitzaBj+dMbhps/vn3SepsO4yrcFwo/huNvDzjgDa6 SlPLoLqLtVopVMjpwynnTpnDC4kxQjSjrEnHcAb/wxEvyv3v22Srp5YIHh0dF8aQ2yvW iwNV1Bby+AE1S7/Cci6wnfx3nMYkVX7Vem/PgmgTuzUjaEt3f3KN9bzcswRf0MLkm4Jc YWIV6qZZMokQITwl8+40lkbZlll2dmGz4YE0OExPqECZvInfdYcki53UPAfq/a9ToXpD NJvA== X-Gm-Message-State: AOAM530wR161nEcjFU1vzxjKFHl3a0uf4mZxpQSSwGowqehZf4cQ6d5+ yuehq0m0v0TjUvGegTNSZpRSh4YqAhnYBg== X-Google-Smtp-Source: ABdhPJw612PJzfSoRFM4YKFFSRunvxT2Q+D+0SKVszPrPGq77yAQrKDLBe+UNsscAVWxb2Of6kXVOQ== X-Received: by 2002:a5d:64ee:: with SMTP id g14mr10904832wri.80.1633312710256; Sun, 03 Oct 2021 18:58:30 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y23sm15349355wmi.16.2021.10.03.18.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 18:58:29 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ben Boeckel , Johannes Schindelin , Heba Waly , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH 5/5] advice.[ch]: sort enum fields in alphabetical order Date: Mon, 4 Oct 2021 03:58:24 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1404.g7bcfc82b295 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These fields have slightly drifted out of order, let's re-order them. Signed-off-by: Ævar Arnfjörð Bjarmason --- advice.c | 2 +- advice.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/advice.c b/advice.c index f7cedac7549..e0ee8ca4f2f 100644 --- a/advice.c +++ b/advice.c @@ -51,9 +51,9 @@ static struct { [ADVICE_PUSH_ALREADY_EXISTS] = { "advice.pushAlreadyExists" }, [ADVICE_PUSH_FETCH_FIRST] = { "advice.pushFetchFirst" }, [ADVICE_PUSH_NEEDS_FORCE] = { "advice.pushNeedsForce" }, - [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "advice.pushRefNeedsUpdate" }, [ADVICE_PUSH_NON_FF_CURRENT] = { "advice.pushNonFFCurrent" }, [ADVICE_PUSH_NON_FF_MATCHING] = { "advice.pushNonFFMatching" }, + [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "advice.pushRefNeedsUpdate" }, [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "advice.pushUnqualifiedRefName" }, [ADVICE_PUSH_UPDATE_REJECTED] = { "advice.pushUpdateRejected" }, [ADVICE_RESET_QUIET_WARNING] = { "advice.resetQuiet" }, diff --git a/advice.h b/advice.h index ab25c6ba9a0..a6aca9684c7 100644 --- a/advice.h +++ b/advice.h @@ -31,9 +31,9 @@ enum advice_type { ADVICE_PUSH_NEEDS_FORCE, ADVICE_PUSH_NON_FF_CURRENT, ADVICE_PUSH_NON_FF_MATCHING, + ADVICE_PUSH_REF_NEEDS_UPDATE, ADVICE_PUSH_UNQUALIFIED_REF_NAME, ADVICE_PUSH_UPDATE_REJECTED, - ADVICE_PUSH_REF_NEEDS_UPDATE, ADVICE_RESET_QUIET_WARNING, ADVICE_RESOLVE_CONFLICT, ADVICE_RM_HINTS,