From patchwork Thu Mar 28 16:14:28 2019 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: 10875265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FA1D17E0 for ; Thu, 28 Mar 2019 16:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B08528B4D for ; Thu, 28 Mar 2019 16:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F22ED28B90; Thu, 28 Mar 2019 16:14:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AABA28B4D for ; Thu, 28 Mar 2019 16:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbfC1QOt (ORCPT ); Thu, 28 Mar 2019 12:14:49 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36434 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfC1QOs (ORCPT ); Thu, 28 Mar 2019 12:14:48 -0400 Received: by mail-wr1-f67.google.com with SMTP id y13so5938294wrd.3 for ; Thu, 28 Mar 2019 09:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Azel+emmJoppX1wRkVgtkK2y/tr9G+gEDkKxNECillo=; b=WfnM7I/5PerRUniulbxpQAVqX6dotMPRWGptUSVR4xRcM3PwkGH0quUxYJCMFUXMxf ZTfnNltcMXLGHKs1a7xvFYJ4B8kLwtK2LGGSPp/pOLHYtKggCSmjQg9lzxJC3juIz4tw SjluL90HUkyh8G85++e0joluhPBdbwgvpWBAji0jqSuidMER80nDv044cSYbP6gop3TK 6DXOF5MKahvHhL1KK5tUX55lwfgvJmaOLlfL4n5X72gje/5sGRutjARWmydZcS5Ja42L n5PYogZOJu/htlMYShvQVedpOvvq7eZGjG5iw5ny+6+IUcxMfPR9pBGo7ndPdoOc0/pr Vpjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Azel+emmJoppX1wRkVgtkK2y/tr9G+gEDkKxNECillo=; b=AgUIrtgTuV22xV2G2BY6/RdpLM52x291TMVg0j6qthq6k7DoEq2/2LFMIUQruPDCwF x63WFx/VlNNWpdLfpE4q1XbFU31/4z3/ajTVjlgfjNKcZLUCWCF7bA3DRVYa7fUd8R1B HkB42C//lWKkvnAAKz3yU5UcFYmgilbTsDQMoGTgH1LlcrVyub0/F7lxiTNliIr9jwne KEievsABzdde9r5TcYBJwInD96f8awYgmDhEd6Tn7QDfIPoCilc94kCYSPQRABD8LI2s AURLG8abSa419gbwlvaKduRzd1HRKH/s4jLHUSyrofA2ZH7ONeKbed/B73z97e6PVPwi MlQg== X-Gm-Message-State: APjAAAVyYo1Q19o4aBO779fz6GzklI03loutTGSxXFAFEuczQ1li4hMO X3NHvLtS+kLsOVyJG1n60hPYLeoX X-Google-Smtp-Source: APXvYqy0fyiTkFTN94SrVSuocX39OybvBg6HhZeCYXG8poAUqeP068e8vjqWJrGo6+/KdYiwmaGQyA== X-Received: by 2002:a5d:4f89:: with SMTP id d9mr27382615wru.195.1553789686545; Thu, 28 Mar 2019 09:14:46 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:45 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 1/7] gc: remove redundant check for gc_auto_threshold Date: Thu, 28 Mar 2019 17:14:28 +0100 Message-Id: <20190328161434.19200-2-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Checking gc_auto_threshold in too_many_loose_objects() was added in 17815501a8 ("git-gc --auto: run "repack -A -d -l" as necessary.", 2007-09-17) when need_to_gc() itself was also reliant on gc_auto_pack_limit before its early return: gc_auto_threshold <= 0 && gc_auto_pack_limit <= 0 When that check was simplified to just checking "gc_auto_threshold <= 0" in b14d255ba8 ("builtin-gc.c: allow disabling all auto-gc'ing by assigning 0 to gc.auto", 2008-03-19) this unreachable code should have been removed. We only call too_many_loose_objects() from within need_to_gc() itself, which will return if this condition holds, and in cmd_gc() which will return before ever getting to "auto_gc && too_many_loose_objects()" if "auto_gc && !need_to_gc()" is true earlier in the function. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/gc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 020f725acc..8c2312681c 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -157,9 +157,6 @@ static int too_many_loose_objects(void) int num_loose = 0; int needed = 0; - if (gc_auto_threshold <= 0) - return 0; - dir = opendir(git_path("objects/17")); if (!dir) return 0; From patchwork Thu Mar 28 16:14:29 2019 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: 10875267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E436A17E0 for ; Thu, 28 Mar 2019 16:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC6E28B73 for ; Thu, 28 Mar 2019 16:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C415828B9C; Thu, 28 Mar 2019 16:14:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D84C28B73 for ; Thu, 28 Mar 2019 16:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbfC1QOw (ORCPT ); Thu, 28 Mar 2019 12:14:52 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]:51336 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfC1QOu (ORCPT ); Thu, 28 Mar 2019 12:14:50 -0400 Received: by mail-wm1-f49.google.com with SMTP id 4so4204064wmf.1 for ; Thu, 28 Mar 2019 09:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EMAcE/X1m7BcvyXZHuHHhBEhMHnX15dn/fKh//SV49U=; b=EtJi2Lxn99Tfz/6BTYIeyGw3udHyXdNClQlvzwxQK8IOzUiYYFWmDkOLmpTpbBWwul 9EcT3M+5UlY6I55PfBr6XSWST5LCPRN4/S0IViRzbqJ7NX4/qkeyCJsCP3BhXGuKU6BO GMi6qX/MeJyUlpQzOKOYUl72GnNxhdNFZ8EB7ricvj0W/Dtyag4mdJ1C3gsRk7nnPBrJ kPjn6ZHCE0NNqCKm4SjlYJmpy/fnF5LsDZW1ErP++HurbRvmBCf4CvH389tq/a1+oUCy QePknJ1nOR5fW9Xko2Oii2rt8veRs8w6BiHalEI9DnHnvMSo5QB0LQ0u5zLfZ1vQTJgj 1lbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EMAcE/X1m7BcvyXZHuHHhBEhMHnX15dn/fKh//SV49U=; b=GC5dja+tqlg0/osGiUhp0Gc5/TVStajgEYpy61Ku6W2yYp2byE/K9mpgkxJG0ct89T 7gT0X5bt7DvVDdMHFnEKeWBvc242ZOPzgpqE4FtsuyJrRhYz+fpSed5hIui/X3DzCoy0 T3q0IFKR9+hN1GBsLU4AVqHPR5P3VQHLF4U+H5QbIg88eaB+qcF/5j8VaPHC203dr0/M ymtLQDNOmidPrLAkddJzDyvdJRcN/f0o74K1Z8RVlqudJPx83FOxwvFalz4p6mzsF7TL ZVtOBpMp7XW4ibe764rTXYqEHpAH9qH1YkcKgeTrtVs5OReYafXPdzgFA7qN0yUNgCMn clkA== X-Gm-Message-State: APjAAAUXJD1yAWha6TZg9nKy9mnUmL+SU7uBIQPkMqtfzyTu0wyve7+S y7hvodh/LPhWZORFNgLZilPsWKB1 X-Google-Smtp-Source: APXvYqwTxR61RZYspdpbJBqlUAqOS+SsAm8jFRmPibxg/8pIGFMnIOQ3bKO+JrENXwfuXRIBWyIANw== X-Received: by 2002:a1c:a70f:: with SMTP id q15mr559162wme.28.1553789688304; Thu, 28 Mar 2019 09:14:48 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:47 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 2/7] gc: convert to using the_hash_algo Date: Thu, 28 Mar 2019 17:14:29 +0100 Message-Id: <20190328161434.19200-3-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's been a lot of changing of the hardcoded "40" values to the_hash_algo->hexsz, but we've so far missed this one where we hardcoded 38 for the loose object file length. This is because a SHA-1 like abcde[...] gets turned into objects/ab/cde[...]. There's no reason to suppose the same won't be the case for SHA-256, and reading between the lines in hash-function-transition.txt the format is planned to be the same. In the future we may want to further modify this code for the hash function transition. There's a potential pathological case here where we'll only consider the loose objects for the currently active hash, but objects for that hash will share a directory storage with the other hash. Thus we could theoretically have e.g. 1k SHA-1 loose objects, and 1 million SHA-256 objects. Then not notice that we need to pack them because we're currently using SHA-1, even though our FS may be straining under the stress of such humongous directories. So assuming that "gc" eventually learns to pack up both SHA-1 and SHA-256 objects regardless of what the current the_hash_algo is, perhaps this check should be changed to consider all files in objects/17/ matching [0-9a-f] 38 or 62 characters in length (i.e. both SHA-1 and SHA-256). But none of that is something we need to worry about now, and supporting both 38 and 62 characters depending on "the_hash_algo" removes another case of SHA-1 hardcoding. As noted in [1] I'm making no effort to somehow remove the hardcoding for "2" as in "use the first two hexdigits for the directory name". There's no indication that that'll ever change, and somehow generalizing it here would be a drop in the ocean, so there's no point in doing that. It also couldn't be done without coming up with some generalized version of the magical "objects/17" directory. See [2] for a discussion of that directory. 1. https://public-inbox.org/git/874l84ber7.fsf@evledraar.gmail.com/ 2. https://public-inbox.org/git/87k1mta9x5.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 8c2312681c..733bd7bdf4 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -156,6 +156,7 @@ static int too_many_loose_objects(void) int auto_threshold; int num_loose = 0; int needed = 0; + const unsigned hexsz_loose = the_hash_algo->hexsz - 2; dir = opendir(git_path("objects/17")); if (!dir) @@ -163,8 +164,8 @@ static int too_many_loose_objects(void) auto_threshold = DIV_ROUND_UP(gc_auto_threshold, 256); while ((ent = readdir(dir)) != NULL) { - if (strspn(ent->d_name, "0123456789abcdef") != 38 || - ent->d_name[38] != '\0') + if (strspn(ent->d_name, "0123456789abcdef") != hexsz_loose || + ent->d_name[hexsz_loose] != '\0') continue; if (++num_loose > auto_threshold) { needed = 1; From patchwork Thu Mar 28 16:14:30 2019 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: 10875269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 995E1186D for ; Thu, 28 Mar 2019 16:14:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 836B128B90 for ; Thu, 28 Mar 2019 16:14:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 772F928B9C; Thu, 28 Mar 2019 16:14:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25E6F28BA3 for ; Thu, 28 Mar 2019 16:14:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbfC1QOw (ORCPT ); Thu, 28 Mar 2019 12:14:52 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35360 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbfC1QOv (ORCPT ); Thu, 28 Mar 2019 12:14:51 -0400 Received: by mail-wm1-f66.google.com with SMTP id y197so2016826wmd.0 for ; Thu, 28 Mar 2019 09:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ohqqasrY0qEc1g14CFfwP5dYF1kZqk/I1BjaGdbOjvw=; b=BG35f/jaHcR8UKoY137vTWmamo0GUgCrbnEO5gjILndEHGMFxNsVKmiLZcPA0VGjfH Sj9OQelu7JUrp+dD5xmPUji1afqWEs7xgj9Dq+QFjcvMYxX+X/pSGmItakFvx88BZ74+ yyHLCAbUh9ed5z9XCgigwpeoK3E2dupqYHVpNKahEpq2HHErxRIXj2wkdSFxsYTvZfcI I2QDFTwmCJEGXY+TyaPiWmS/tv9rOIRDKkmEyt4TL6KQXlDCzU0EiN5/rMODhqKofIzl 8o3dQY2jEfv3gAreyj91WwJeanIcLnIch34vIvt8Gg2/LVhTY5qnJXQwuWhFTTkgI7M7 TCWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ohqqasrY0qEc1g14CFfwP5dYF1kZqk/I1BjaGdbOjvw=; b=AFat+xtF7ebLqEWbOzBAk8JySzm688jD4K9TIgLs1ITnmqELpZHEJNyXnXC0FAGvSh unKTdPFWEEGOYWNWQyff/ikn+ZVCDmRDQs8vdpDJosai0dpAkUxlfnc1Ju/j3QTqKNEs ekjUY7/3/GC2eedJb2r/GLnotqMV217vOF8KZdeb7S63twwEMesAY3zRmhWj66AaeDCU 1xZzBR/M/htocgQdVOtbcPTQFnbfRwO1Ez2lGao9pxue+nN/XYpSBIo22iDefvvst1YH xK1K2/oz3/XkdEX33qvOgFWOILdcwyI3V8KAgwe5sxc41JwuHIcqeFgpZevReumr0cU/ THLA== X-Gm-Message-State: APjAAAUA874YPPtfRSihMzWlkafDAZnyC3RfudNje+MTxh4XyJ0qYuAS J6j/UCMDEVZ95JCdv5v19rvqUaF4 X-Google-Smtp-Source: APXvYqym0c6R6mvnOYQkzYDXW3VOyuvwPE6Mu8MVvfMSZ7rSrx4R78svuwj9bYjcZrwABoALKmxulA== X-Received: by 2002:a05:600c:cd:: with SMTP id u13mr503917wmm.49.1553789689552; Thu, 28 Mar 2019 09:14:49 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:48 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 3/7] gc: refactor a "call me once" pattern Date: Thu, 28 Mar 2019 17:14:30 +0100 Message-Id: <20190328161434.19200-4-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change an idiom we're using to ensure that gc_before_repack() only does work once (see 62aad1849f ("gc --auto: do not lock refs in the background", 2014-05-25)) to be more obvious. Nothing except this function cares about the "pack_refs" and "prune_reflogs" variables, so let's not leave the reader wondering if they're being zero'd out for later use somewhere else. Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/gc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 733bd7bdf4..ae716a00d4 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -489,14 +489,20 @@ static int report_last_gc_error(void) static void gc_before_repack(void) { + /* + * We may be called twice, as both the pre- and + * post-daemonized phases will call us, but running these + * commands more than once is pointless and wasteful. + */ + static int done = 0; + if (done++) + return; + if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD)) die(FAILED_RUN, pack_refs_cmd.argv[0]); if (prune_reflogs && run_command_v_opt(reflog.argv, RUN_GIT_CMD)) die(FAILED_RUN, reflog.argv[0]); - - pack_refs = 0; - prune_reflogs = 0; } int cmd_gc(int argc, const char **argv, const char *prefix) From patchwork Thu Mar 28 16:14:31 2019 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: 10875273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2E0017E0 for ; Thu, 28 Mar 2019 16:14:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DE7428B4D for ; Thu, 28 Mar 2019 16:14:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8223328B90; Thu, 28 Mar 2019 16:14:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36FB528B4D for ; Thu, 28 Mar 2019 16:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfC1QOz (ORCPT ); Thu, 28 Mar 2019 12:14:55 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:44636 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbfC1QOx (ORCPT ); Thu, 28 Mar 2019 12:14:53 -0400 Received: by mail-wr1-f42.google.com with SMTP id y7so19492876wrn.11 for ; Thu, 28 Mar 2019 09:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0OrYW0SN8tkBewlpvNwKRkXnGPnUDO/Qv15OMaVKJBM=; b=l6a0RZ3rH96gh+NtM9Kop0zHDEg7oMBL7JUDoLCZeyWqzD3XsEPFQZVctSEidKV7U/ W01EPyewBf62Vb/OIqbk+cQL0eAtzHgGBwrTirD7NIzODAJMq9vdlw2B1qK2Y0CTP9Mv bAPDvk6UMnfzxnPajQAJdPDhrfenGldhgwvVmtXFFr7T32OFvWUfwdcKq8g/o56zHnKJ LWGutAhnv0bTqVHc/ONnAPbAMBiSUJGyFHOAX7v0e0x38UsQfKdlNuy4ZbzWeJS8PH7/ fAgNvkVGeATG8UPgWOf2uR8NgKBwIPAqyP8azh2M6thtzSdNwlmbxbrOuT7oNDV8lCqB au/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0OrYW0SN8tkBewlpvNwKRkXnGPnUDO/Qv15OMaVKJBM=; b=L4olQl8ep7eMEAOEmCOJRx9f20HRvWxsfRV6eqiV6GN3aYCvmEKjoCRl1LBbp0yy4D 8L/H/l8oqpGDk0ZklM9tvnnt41ovHdTT1LJ2H1SpYXvc6/LSB8r/H54G6vyRrfMjA2dS WcsN/siANgPhGPzpkd/7MVl3AiFNFs8F7CHy25aCywL9htXNVzlb+xFjDWpuFIHOaZXQ /GifDp/EKV0pCM5QHAxxQp6QtTF2TpZFkR3ygKXG0yugEMuQ1KghL8XowWmWPLJqZYBA 35CLlNo8m4zrP/AYHALB0g9KMVRJsnGoy01pfJOIfKxlSWxSsANhEbflIRDjxtRq8k3G Cw6w== X-Gm-Message-State: APjAAAWU2SqJrESawFM7GtPZdD4ggg+F/H1l0+F51I6EIaU8OT875ROD rpXoUI25xYbkWOJY7xbMcbtzRYHn X-Google-Smtp-Source: APXvYqzcg79+8RO+VTBh+8HyYuw5IoAh9DRGaag2Gl34rMvvQf6r0Yi9aIQ9zniVhUlbrl2PJQMHAw== X-Received: by 2002:adf:f1c6:: with SMTP id z6mr7923616wro.232.1553789690961; Thu, 28 Mar 2019 09:14:50 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:49 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 4/7] reflog tests: make use of "test_config" idiom Date: Thu, 28 Mar 2019 17:14:31 +0100 Message-Id: <20190328161434.19200-5-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change a couple of tests that weren't using the helper to use it. This makes the trailing "--unset" unnecessary. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1410-reflog.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ae8a448e34..42f5ac9ed9 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -232,24 +232,21 @@ test_expect_success '--expire=never' ' ' test_expect_success 'gc.reflogexpire=never' ' + test_config gc.reflogexpire never && + test_config gc.reflogexpireunreachable never && - git config gc.reflogexpire never && - git config gc.reflogexpireunreachable never && git reflog expire --verbose --all && git reflog refs/heads/master >output && test_line_count = 4 output ' test_expect_success 'gc.reflogexpire=false' ' + test_config gc.reflogexpire false && + test_config gc.reflogexpireunreachable false && - git config gc.reflogexpire false && - git config gc.reflogexpireunreachable false && git reflog expire --verbose --all && git reflog refs/heads/master >output && - test_line_count = 4 output && - - git config --unset gc.reflogexpire && - git config --unset gc.reflogexpireunreachable + test_line_count = 4 output ' From patchwork Thu Mar 28 16:14:32 2019 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: 10875271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBFFC17E0 for ; Thu, 28 Mar 2019 16:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D711C28B4D for ; Thu, 28 Mar 2019 16:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB6B828B90; Thu, 28 Mar 2019 16:14:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B13728B4D for ; Thu, 28 Mar 2019 16:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbfC1QOz (ORCPT ); Thu, 28 Mar 2019 12:14:55 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]:53169 "EHLO mail-wm1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfC1QOy (ORCPT ); Thu, 28 Mar 2019 12:14:54 -0400 Received: by mail-wm1-f53.google.com with SMTP id a184so4198967wma.2 for ; Thu, 28 Mar 2019 09:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=luL8kTgjIVASvqVkUPhlJxRfwjVsqTYlqLdiKMpuQ2Y=; b=KY7GJ6DMIEtUc1HU3R8crhX6c4QaS/NJ1u5pGtlVFalLX7PtCGq4bApR6uRix0Hp3c 5ymz85IMH38ITb9d6jfsxl2HLBEA5z3fRcwy653kiORZAw3BW/YXJrR0VnheYObeHe09 dE7PnKJBBNaBtHNY8oyzLIQggYo7LI8PuFlZT/7qRVWvkoIr3rYSl77yGeCdNq6eekvs NtTRqr3+j9eksLDh082g4oNB/pzrIbYvo5h9/X+h76lCOUfr7x3MIR/+Ps7YodnqBDcR EnELB2LoUBk/rbmoXuPjDo+3y8JvsY3YTb5qf2nYL43Zn6kpdUEuznBya9E9D4xiKO5c +LNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=luL8kTgjIVASvqVkUPhlJxRfwjVsqTYlqLdiKMpuQ2Y=; b=PbaBuTXbKPEyCINJ4Tau4kigVjrZ/2pW7rA9AvNlUmsUSz8zM1Dbg0SWcXaTSs74BB 1MQdNcW+j80uKqOg6d/NAd2vnWxxqwojltGE2sTfVz3iPePtEtQwCtLdrQvYLL+5MyiS Uitu4L0RVyHs2eoRbbv9u4vFPWQVDqjskokDrmNv17nWNTEL5ig3lsnHICz6eDdpNnq0 wAcHX/2F9HN8oQEP08GvmtDuMpeXe9pzNh5TcMFgh6ahLoM0iw5CA8VDG8gjFfn5OUeK mHMREjOqNTDc7Zd+fZWw9HCRGyv0E4dZiqqwfsFS6Ho7G/PDhQO5CaL6De6nssDmlV8W 3xAw== X-Gm-Message-State: APjAAAUgaNvnRayCB4UJqiJUKGD9EDNQHIxF1l2juoPuj9A85cfOHN8a t8R53fpdbwDxrudbD9mtDHbfX2/oTzY= X-Google-Smtp-Source: APXvYqyCVEiP1x/E0AK4bxI/hgF3D/qVZLaUJQM3X8t5HvjPcQdZsHsdy7tSq9z+MFHcFh4rT1LGbw== X-Received: by 2002:a7b:c767:: with SMTP id x7mr591731wmk.6.1553789692429; Thu, 28 Mar 2019 09:14:52 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:51 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 5/7] reflog tests: test for the "points nowhere" warning Date: Thu, 28 Mar 2019 17:14:32 +0100 Message-Id: <20190328161434.19200-6-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "git reflog expire" command when given an unknown reference has since 4264dc15e1 ("git reflog expire", 2006-12-19) when this command was implemented emit an error, but this has never been tested for. Let's test for it, also under gc.reflogExpire{Unreachable,}=never in case a future change is tempted to take shortcuts in the presence of such config. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1410-reflog.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 42f5ac9ed9..e8f8ac9785 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -250,6 +250,16 @@ test_expect_success 'gc.reflogexpire=false' ' ' +test_expect_success 'git reflog expire unknown reference' ' + test_config gc.reflogexpire never && + test_config gc.reflogexpireunreachable never && + + test_must_fail git reflog expire master@{123} 2>stderr && + test_i18ngrep "points nowhere" stderr && + test_must_fail git reflog expire does-not-exist 2>stderr && + test_i18ngrep "points nowhere" stderr +' + test_expect_success 'checkout should not delete log for packed ref' ' test $(git reflog master | wc -l) = 4 && git branch foo && From patchwork Thu Mar 28 16:14:33 2019 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: 10875277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59811186D for ; Thu, 28 Mar 2019 16:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 450C428B4D for ; Thu, 28 Mar 2019 16:15:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3935528B90; Thu, 28 Mar 2019 16:15:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAD6328B4D for ; Thu, 28 Mar 2019 16:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbfC1QO5 (ORCPT ); Thu, 28 Mar 2019 12:14:57 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37361 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbfC1QO4 (ORCPT ); Thu, 28 Mar 2019 12:14:56 -0400 Received: by mail-wr1-f65.google.com with SMTP id w10so23643774wrm.4 for ; Thu, 28 Mar 2019 09:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cXlEvWIWuf0LfwswZtIl3cIBvHeegqhbRdOcFQ8IUNo=; b=UtvZcgeLKNdzMqztBG52aTPTTyG2I+x4oJ7KrKu/hlWBPQQEKEwJSPDeL8/tI9eHZG qM01G+nkK4RvImGflWPNU9vg02sj4Z7PhgpYdVwg/AZxdIearEdA5+xIFiF1WylmtK6f nLtQwMASYxb+9O4jQQWioD8tsezec+JfxZxC8DVLpgmU8YWiWrAsipN5OXAn4WoGxDz5 aUiOlQ0cJlBgnwoz4+juOZe/7w4fOq4a2rdk5QXlfLJ76HPs5Yz1J3dbw8Sb57oiTc3Y omOaBICYj/xRXwOa44xATrYB15rRhD2XZU3xhRG3ILNUV5moA9MUiNoRGDB/D7aBTLV0 xM/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cXlEvWIWuf0LfwswZtIl3cIBvHeegqhbRdOcFQ8IUNo=; b=ZrOESkxtu77EwOFqxClUR6jTgV7oXKdwf9mDo585QfwcbVgzO8AdAA3lKc9gDkNrF/ lNWifKPmystZor+Sc4NDlQ+u2xDA98lD69uBO89Ak5Mmo/KwtpHX8414UxXcDeoSjkJN wZ9EptuWT530blpdXGoQCSgjagHOsw4U0ERT2Qij593UKzoFwlMlz8HpPxXfT2RJJZRt 4zqgiHsbjcvboaA4ct8uF1SdzwPIiE2sQydPoTAcZ7Dtb1Jf3Qc6MELRxlyKg/pV/AZB fwdpL2JuDfZzKXHb+Kz7eLUkE4Qf9ACM9xO5W9gb+8NQto11k3uqbGXg9WSKFtDX4oT8 BqDw== X-Gm-Message-State: APjAAAXY1h0gMsPora+jHQRYcGIxD5/O+Zc125TPEiX3n915n2+Ku6/8 aF0NYNoOdbFiSm8gRxOwjh0yUdQzNpQ= X-Google-Smtp-Source: APXvYqxxHCsYVK9VH+vn7TH4RjlycB+0V3If1I7ZPm5mnY+WnVa+KKWJuR/zWDM6gOfYokR+4aloSA== X-Received: by 2002:adf:fd43:: with SMTP id h3mr26923392wrs.310.1553789693738; Thu, 28 Mar 2019 09:14:53 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:52 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 6/7] reflog tests: assert lack of early exit with expiry="never" Date: Thu, 28 Mar 2019 17:14:33 +0100 Message-Id: <20190328161434.19200-7-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When gc.reflogExpire and gc.reflogExpireUnreachable are set to "never" and --stale-fix isn't in effect we *could* exit early without pointlessly looping over all the reflogs. However, as an earlier change to add a test for the "points nowhere" warning shows even in such a mode we might want to print out a warning. So while it's conceivable to implement this, I don't think it's worth it. It's going to be too easy to inadvertently add some flag that'll make the expiry happen anyway, and even with "never" we'd like to see all the lines we're going to keep. So let's assert that we're going to loop over all the references even when this configuration is in effect. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1410-reflog.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index e8f8ac9785..79f731db37 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -235,7 +235,9 @@ test_expect_success 'gc.reflogexpire=never' ' test_config gc.reflogexpire never && test_config gc.reflogexpireunreachable never && - git reflog expire --verbose --all && + git reflog expire --verbose --all >output && + test_line_count = 9 output && + git reflog refs/heads/master >output && test_line_count = 4 output ' From patchwork Thu Mar 28 16:14:34 2019 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: 10875275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D421217E0 for ; Thu, 28 Mar 2019 16:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF6C328B4D for ; Thu, 28 Mar 2019 16:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B408E28B90; Thu, 28 Mar 2019 16:14:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4170528B4D for ; Thu, 28 Mar 2019 16:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbfC1QO6 (ORCPT ); Thu, 28 Mar 2019 12:14:58 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45252 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfC1QO5 (ORCPT ); Thu, 28 Mar 2019 12:14:57 -0400 Received: by mail-wr1-f66.google.com with SMTP id s15so23622671wra.12 for ; Thu, 28 Mar 2019 09:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZJvTU3k0qMmPHSAq9eKvNiRlibzp+mODk3qXX35Wsb4=; b=ruGbbdAYCMtNU9g0UeyFkZe5H2MEdpzFhNeVk+LlTz4S9MrenO1eQJRgYJmlggh8h4 2QAGhY5jYhrwh/vHb5tt5UHvpeGnNJhjBjniZ5ix5q4EORXDySsvH5Lafi7BgXkVG2kt qs7kgbbp/ptjqhjqM+U2BvhC5nEMLNFgLVXeWSgwh3L6MFtasBYYcScytY7tnwJTi0+D tGF+1BQbQDS07F4WcW8QALYBprgjdjN/RBOzLFJBGQnqf792H7VxJutYnHXve5c0f6uX d+paIzDeJXKwkG3DUQMMidfANgRUFS9+1JkBGuPzFyTNAO511CMRkOYev73gzpvAsj9e t7iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZJvTU3k0qMmPHSAq9eKvNiRlibzp+mODk3qXX35Wsb4=; b=RE1LJLQOcbA6fbH3PCAHfEga8p2OFqKF1VF6Mw8eLRUwI2z1qRbMVWlCtq2SvqRRc0 I4dJ3h3Qvwrbp7jIhXrdU1q4T7yA9qjBhUmbI1tBKbG508fRihKzj2Ii8hWnLMftRFPD 2UpkwdYV8TEFq6vNuzmfVpQAFomSN5Jny2SOIF9I0vmYSG8o7kqeNdyCErZWWdeuIh6e MNMAyC7oDhFaTbZpk9WZBR5B/Bvdg9TfqM4k15b5Siqo4VdsOO7aAVlBMPQ3wLlb+ESh 8CQjNJmO6BfsdzDg0671E3zni9mpuho+oKIOOJuTEAT4DSutuoI50zRCAD+6q5S6wVBS HCyw== X-Gm-Message-State: APjAAAWfChtQNGQ0FMIpArCR/Xggg8y5v7SeKOlNMGsyvpoNlk+3jyP9 /eIJiMlWRg6hz/t76X7u7uHjPKSFsGY= X-Google-Smtp-Source: APXvYqxVsP1WvG5Ttb/ral8yQeHqucp/iOAw6OfWXitWnZkG+gwnT5BvSsZqpn6XJEuvs6zZ9ajhfA== X-Received: by 2002:a5d:6181:: with SMTP id j1mr27215546wru.11.1553789694869; Thu, 28 Mar 2019 09:14:54 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id d14sm25519089wro.79.2019.03.28.09.14.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 28 Mar 2019 09:14:54 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , Michael Haggerty , Stefan Beller , Jonathan Nieder , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 7/7] gc: handle & check gc.reflogExpire config Date: Thu, 28 Mar 2019 17:14:34 +0100 Message-Id: <20190328161434.19200-8-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e In-Reply-To: <20190315155959.12390-1-avarab@gmail.com> References: <20190315155959.12390-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't redundantly run "git reflog expire --all" when gc.reflogExpire and gc.reflogExpireUnreachable are set to "never", and die immediately if those configuration valuer are bad. As an earlier "assert lack of early exit" change to the tests for "git reflog expire" shows, an early check of gc.reflogExpire{Unreachable,} isn't wanted in general for "git reflog expire", but it makes sense for "gc" because: 1) Similarly to 8ab5aa4bd8 ("parseopt: handle malformed --expire arguments more nicely", 2018-04-21) we'll now die early if the config variables are set to invalid values. We run "pack-refs" before "reflog expire", which can take a while, only to then die on an invalid gc.reflogExpire{Unreachable,} configuration. 2) Not invoking the command at all means it won't show up in trace output, which makes what's going on more obvious when the two are set to "never". 3) As a later change documents we lock the refs when looping over the refs to expire, even in cases where we end up doing nothing due to this config. For the reasons noted in the earlier "assert lack of early exit" change I don't think it's worth it to bend over backwards in "git reflog expire" itself to carefully detect if we'll really do nothing given the combination of all its possible options and skip that locking, but that's easy to detect here in "gc" where we'll only run "reflog expire" in a relatively simple mode. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/gc.c | 17 +++++++++++++++++ t/t6500-gc.sh | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/builtin/gc.c b/builtin/gc.c index ae716a00d4..8943bcc300 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -116,6 +116,19 @@ static void process_log_file_on_signal(int signo) raise(signo); } +static int gc_config_is_timestamp_never(const char *var) +{ + const char *value; + timestamp_t expire; + + if (!git_config_get_value(var, &value) && value) { + if (parse_expiry_date(value, &expire)) + die(_("failed to parse '%s' value '%s'"), var, value); + return expire == 0; + } + return 0; +} + static void gc_config(void) { const char *value; @@ -127,6 +140,10 @@ static void gc_config(void) pack_refs = git_config_bool("gc.packrefs", value); } + if (gc_config_is_timestamp_never("gc.reflogexpire") && + gc_config_is_timestamp_never("gc.reflogexpireunreachable")) + prune_reflogs = 0; + git_config_get_int("gc.aggressivewindow", &aggressive_window); git_config_get_int("gc.aggressivedepth", &aggressive_depth); git_config_get_int("gc.auto", &gc_auto_threshold); diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index 4684d06552..7411bf7fec 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -120,6 +120,25 @@ test_expect_success 'gc --quiet' ' test_must_be_empty stderr ' +test_expect_success 'gc.reflogExpire{Unreachable,}=never skips "expire" via "gc"' ' + test_config gc.reflogExpire never && + test_config gc.reflogExpireUnreachable never && + + GIT_TRACE=$(pwd)/trace.out git gc && + + # Check that git-pack-refs is run as a sanity check (done via + # gc_before_repack()) but that git-expire is not. + grep -E "^trace: (built-in|exec|run_command): git pack-refs --" trace.out && + ! grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out +' + +test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "expire" via "gc"' ' + >trace.out && + test_config gc.reflogExpire never && + GIT_TRACE=$(pwd)/trace.out git gc && + grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out +' + run_and_wait_for_auto_gc () { # We read stdout from gc for the side effect of waiting until the # background gc process exits, closing its fd 9. Furthermore, the