From patchwork Thu Feb 3 21:40:11 2022 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: 12734665 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87B8CC433EF for ; Thu, 3 Feb 2022 21:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbiBCVk3 (ORCPT ); Thu, 3 Feb 2022 16:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346643AbiBCVk1 (ORCPT ); Thu, 3 Feb 2022 16:40:27 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35725C061714 for ; Thu, 3 Feb 2022 13:40:27 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id v13so7552330wrv.10 for ; Thu, 03 Feb 2022 13:40:27 -0800 (PST) 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=LGR9v8jgDa064A6lFqXuC3ANrQPDF7L/rPhH0SbCZq4=; b=ezjH7yH4P2eFY5GrPfXgRS/8uXVDM9K8WbsxEpGEWoPUNzYGV6vQ+tOu8WSgo0ESAF GrtNXIxy5Qg8k9WCohtQMr4IOGvPw1jRqW7Fn7BRjGAt5Dzg36XI9vegymbCT46jPuYO lfNMSx7ui+m/jbdC/ZEMkEJ0kEbz6g5Xaww2R7H4FEWELhcIgsPlA1aWkSncOIEG7Hvq c73zpsp8ZZkZDdMixf5yenNQaYgpzi+TYQjnsRTX+ZLvX5aFFdYBg4nRk8edchnlNQ1x J/ZpmKh4TI+g0soATKgQOkRcqt+7YY+Hl+4yqSggMiSph31BLa3FCI+i5ZOOWB5+Yu6+ 16qw== 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=LGR9v8jgDa064A6lFqXuC3ANrQPDF7L/rPhH0SbCZq4=; b=HrMFhsr/ztYpXQ5n6b9Kwye5fa58+ZqPn75AtWH5Kjagp4RGEZTqvHvBJ7ntzBg1XT NGJ0HK0+AGq78q4+Wk8lpksKC8PY3xYEV+AvEXR9VAP3L7XWPFExVdRffy+71qE2r8wM Ap/gxqumyu1t1wRnAtEqcIlHrd03Llgguj4sCumkxUxL0F5fVMhg9hyP3WybEF6ewyFQ tQ3OlOlGPLsNTaehoV+WeKj1F81Qm+92YLlw1GH+fvkQNkNlbifM0/T+lgr/4Js5IgSo F5lDun64D1UXG7Ll+htM52MaWx4qLlzXrU4nNn9ZpLX8tTsuIK/+gUQWiLjIe5erwsVZ b3cQ== X-Gm-Message-State: AOAM531253aDpTjwmhMvcRx7LmxJBphQrq4hzS14B+JysAI33mB84xAM wP/GcdrKkdXVVaZ69boIs63kvj+vaes= X-Google-Smtp-Source: ABdhPJwpGTv74h3hZNUdqLMxC/F2zp9w6ybNq36NVHK0lpmC30AJM+Bp0x87X++S1AwGR6mJKAGHGQ== X-Received: by 2002:a5d:6da4:: with SMTP id u4mr30766207wrs.611.1643924425509; Thu, 03 Feb 2022 13:40:25 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:24 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= , Johannes Altmanninger , Emily Shaffer , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v9 1/9] leak tests: fix a memory leak in "test-progress" helper Date: Thu, 3 Feb 2022 22:40:11 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak in the test-progress helper, and mark the corresponding "t0500-progress-display.sh" test as being leak-free under SANITIZE=leak. This fixes a leak added in 2bb74b53a4 (Test the progress display, 2019-09-16). My 48f68715b14 (tr2: stop leaking "thread_name" memory, 2021-08-27) had fixed another memory leak in this test (as it did some trace2 testing). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-progress.c | 1 + t/t0500-progress-display.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c index 5d05cbe7894..9265e6ab7cf 100644 --- a/t/helper/test-progress.c +++ b/t/helper/test-progress.c @@ -69,6 +69,7 @@ int cmd__progress(int argc, const char **argv) die("invalid input: '%s'\n", line.buf); } stop_progress(&progress); + strbuf_release(&line); return 0; } diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index 22058b503ac..f37cf2eb9c9 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -2,6 +2,7 @@ test_description='progress display' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh show_cr () { From patchwork Thu Feb 3 21:40:12 2022 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: 12734667 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13A92C433F5 for ; Thu, 3 Feb 2022 21:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355092AbiBCVk3 (ORCPT ); Thu, 3 Feb 2022 16:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354612AbiBCVk2 (ORCPT ); Thu, 3 Feb 2022 16:40:28 -0500 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 40343C061714 for ; Thu, 3 Feb 2022 13:40:28 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id g18so7240529wrb.6 for ; Thu, 03 Feb 2022 13:40:28 -0800 (PST) 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=Q4mjH1r0wOD0MH5Sja+kmSJz5V8v4vi8pZD+G+KLSxg=; b=aJrxfW3vst6asCvkoWfLcsTTqdsmKGY/SBXRoh4Uro6IvwWuKxzNxssdi6dwDXqQol 7aPr6v2ITZE2zLn6jv5qBFiDN13w1h8z9TNIwdPu5hqN1g7i9Ou5HHn0t8VPXL3hxB+D uM1OfJoDVGs3wv7o8T7T5x5Vid3s8AWrhg2K4rMMrySB5qaolwxPJnCVTrDudqVifojx p7tg7fRXub5FlQWRIhJVu0NsPqO9bbYxrYgnOpCb/zJK/PnvW/BsoUSKjBoh4ctz8Dt6 9IFuO0HxsvjqjEIRWY9texyS6oC43TAjzd6YKFtsWbIJcUkkNBv5s+wpcz3oX0yAz5u3 oXTQ== 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=Q4mjH1r0wOD0MH5Sja+kmSJz5V8v4vi8pZD+G+KLSxg=; b=MB4vIOtCb433ivrt2WuOStd+1gQML9RhGlrT3tiMPQ0nbpoDurHZyuhjwzDlNklVih 6nmiBJ/qqiugGgAIKAEIYRoEMsTI7CfaURtHiRh1y7MYoDBurCUq5tQdW1+Nh7zyQs61 z+ObBsWPZxoEm4SSNZWWxlZ0fYFMQ9obyzti8rJa7RLnRqQBvybGbqC5xNigLGaA2UO1 lYP2vyzmDnTXBNEFTD7uOdgpum7acZqKDF3e9eMTyfpnf6bMqJNUDrqEw9oHiiN9YjoH AIM+8uLQUWXQrv9uDYJN+ZPVWETJkGcOlrldwhT7PaUyUx3YmW0HQF2kWoQiF2SDRixG 1cHg== X-Gm-Message-State: AOAM532xgQIW3C3mmiYdMzyupRWfGUUr1L0Eq0mxNv+XStegF0rUDp0u F5QdpgEEA2jRWHBtzYT5CUylqL/RPuJQBg== X-Google-Smtp-Source: ABdhPJxLrjXOwNiiJoDSPhsr5nswhjPdG/1ZchTbUzB0x47EBlyWjHHus8KpL4qdT1aFgdy7HFlQhg== X-Received: by 2002:a05:6000:1885:: with SMTP id a5mr29972999wri.705.1643924426535; Thu, 03 Feb 2022 13:40:26 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:25 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= , Johannes Altmanninger , Emily Shaffer , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v9 2/9] progress.c test helper: add missing braces Date: Thu, 3 Feb 2022 22:40:12 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If we have braces on one arm of an if/else all of them should have it, per the CodingGuidelines's "When there are multiple arms to a conditional[...]" advice. This formatting change makes a subsequent commit smaller. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-progress.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c index 9265e6ab7cf..50fd3be3dad 100644 --- a/t/helper/test-progress.c +++ b/t/helper/test-progress.c @@ -63,10 +63,11 @@ int cmd__progress(int argc, const char **argv) die("invalid input: '%s'\n", line.buf); progress_test_ns = test_ms * 1000 * 1000; display_throughput(progress, byte_count); - } else if (!strcmp(line.buf, "update")) + } else if (!strcmp(line.buf, "update")) { progress_test_force_update(); - else + } else { die("invalid input: '%s'\n", line.buf); + } } stop_progress(&progress); strbuf_release(&line); From patchwork Thu Feb 3 21:40:13 2022 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: 12734671 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80EC0C433EF for ; Thu, 3 Feb 2022 21:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355310AbiBCVkr (ORCPT ); Thu, 3 Feb 2022 16:40:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355169AbiBCVk3 (ORCPT ); Thu, 3 Feb 2022 16:40:29 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E35EC061714 for ; Thu, 3 Feb 2022 13:40:29 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id v123so3116813wme.2 for ; Thu, 03 Feb 2022 13:40:29 -0800 (PST) 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=mF5Pc7bcl4aJJy7La1bysKZi32XbJE4/rywyjZackiI=; b=YLsYSsdanb6xwGaZBlrKNrQAiUoFSepSVxdslxp4igDtaNMT53jqL3MNpiI7xwQUB5 cIyayhel/RaSymilAWRmBhfiiKzaS9eL4P7O8uvZOCry0967J5xiiAFqqc+F4OYJ7Q/P Fps8ckqkawpziccNUItNpILdqRyRsLqSqd0Ax+esGnpGXR520c1xwWsj8gGbmQKR7hSs J864nbKBvqSDDaidjl7HshzvtIBHRdtoYX3w1IHO+Klmx3Wh/ffuCrePbJ8SVSK6hoK1 AXOyuJz2AT1vGFB1F6l6/IaEw13Bvpi8SSgovHBIc70oB9E661ndGacPVsXRYnjMC3LG qSBA== 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=mF5Pc7bcl4aJJy7La1bysKZi32XbJE4/rywyjZackiI=; b=G+5lw8ixj5K3eGQEJ3HaSPjilY7+YhzyaTvKsWlIJjNEHlJW4/iHhbNt3CekXyuJdT fjMnOCPEjrkvxBUFUzn/WfvTUURACP7/TYgS3NZ9mNksqDMcw4Lvy/W4iTLjt1OXd16w 7uyXuy8Y2/r3L86tkixjlXNlkcc4QBwYP0nPg3exooPiuAW4MuDCtDBwBHn+I8S6K+NF 0KgrsOYFdqRRd/I+RNkg8xTuWFGfpPWXX45IXGH3DLneG3qpOKeXw6S6oVhsxQYS7+Ff jzlLkX7L28WvdccdygguJdW36kf6U/MTQ1jXw11IoGfk/2KFxGA8HV06LnwkOhdmuClD Hjbw== X-Gm-Message-State: AOAM531TqPJA+59lHXAYlDgKfAZxWIMjEfpqS2dnTo4Fjla9ULLZt23o x1lu1AF6Xxo1PXN+0HuxCuYKNsTLgLNbuQ== X-Google-Smtp-Source: ABdhPJwQFbX9R6v3/T8EXq6rPnkAFlcZw2ktJz4JVeaiKAYKn88clgkzzh3fx+zW75peJ2aTQEoczw== X-Received: by 2002:a05:600c:4112:: with SMTP id j18mr12193419wmi.72.1643924427541; Thu, 03 Feb 2022 13:40:27 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:26 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= , Johannes Altmanninger , Emily Shaffer , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v9 3/9] progress.c tests: make start/stop commands on stdin Date: Thu, 3 Feb 2022 22:40:13 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the usage of the "test-tool progress" introduced in 2bb74b53a49 (Test the progress display, 2019-09-16) to take command like "start" and "stop" on stdin, instead of running them implicitly. This makes for tests that are easier to read, since the recipe will mirror the API usage, and allows for easily testing invalid usage that would yield (or should yield) a BUG(), e.g. providing two "start" calls in a row. A subsequent commit will add such tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-progress.c | 44 +++++++++++++++++++++------- t/t0500-progress-display.sh | 58 +++++++++++++++++++++++-------------- 2 files changed, 70 insertions(+), 32 deletions(-) diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c index 50fd3be3dad..6cc9735b601 100644 --- a/t/helper/test-progress.c +++ b/t/helper/test-progress.c @@ -3,6 +3,9 @@ * * Reads instructions from standard input, one instruction per line: * + * "start [ ]" - Call start_progress(title, total), + * Uses the default title of "Working hard" + * if the " <title>" is omitted. * "progress <items>" - Call display_progress() with the given item count * as parameter. * "throughput <bytes> <millis> - Call display_throughput() with the given @@ -10,6 +13,7 @@ * specify the time elapsed since the * start_progress() call. * "update" - Set the 'progress_update' flag. + * "stop" - Call stop_progress(). * * See 't0500-progress-display.sh' for examples. */ @@ -19,34 +23,50 @@ #include "parse-options.h" #include "progress.h" #include "strbuf.h" +#include "string-list.h" int cmd__progress(int argc, const char **argv) { - int total = 0; - const char *title; + const char *const default_title = "Working hard"; + struct string_list titles = STRING_LIST_INIT_DUP; struct strbuf line = STRBUF_INIT; - struct progress *progress; + struct progress *progress = NULL; const char *usage[] = { - "test-tool progress [--total=<n>] <progress-title>", + "test-tool progress <stdin", NULL }; struct option options[] = { - OPT_INTEGER(0, "total", &total, "total number of items"), OPT_END(), }; argc = parse_options(argc, argv, NULL, options, usage, 0); - if (argc != 1) - die("need a title for the progress output"); - title = argv[0]; + if (argc) + usage_with_options(usage, options); progress_testing = 1; - progress = start_progress(title, total); while (strbuf_getline(&line, stdin) != EOF) { char *end; - if (skip_prefix(line.buf, "progress ", (const char **) &end)) { + if (skip_prefix(line.buf, "start ", (const char **) &end)) { + uint64_t total = strtoull(end, &end, 10); + const char *title; + + /* + * We can't use "end + 1" as an argument to + * start_progress(), it doesn't xstrdup() its + * "title" argument. We need to hold onto a + * valid "char *" for it until the end. + */ + if (!*end) + title = default_title; + else if (*end == ' ') + title = string_list_insert(&titles, end + 1)->string; + else + die("invalid input: '%s'\n", line.buf); + + progress = start_progress(title, total); + } else if (skip_prefix(line.buf, "progress ", (const char **) &end)) { uint64_t item_count = strtoull(end, &end, 10); if (*end != '\0') die("invalid input: '%s'\n", line.buf); @@ -65,12 +85,14 @@ int cmd__progress(int argc, const char **argv) display_throughput(progress, byte_count); } else if (!strcmp(line.buf, "update")) { progress_test_force_update(); + } else if (!strcmp(line.buf, "stop")) { + stop_progress(&progress); } else { die("invalid input: '%s'\n", line.buf); } } - stop_progress(&progress); strbuf_release(&line); + string_list_clear(&titles, 0); return 0; } diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index f37cf2eb9c9..27ab4218b01 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -18,6 +18,7 @@ test_expect_success 'simple progress display' ' EOF cat >in <<-\EOF && + start 0 update progress 1 update @@ -26,8 +27,9 @@ test_expect_success 'simple progress display' ' progress 4 update progress 5 + stop EOF - test-tool progress "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -42,11 +44,13 @@ test_expect_success 'progress display with total' ' EOF cat >in <<-\EOF && + start 3 progress 1 progress 2 progress 3 + stop EOF - test-tool progress --total=3 "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -63,14 +67,14 @@ Working hard.......2.........3.........4.........5.........6: EOF cat >in <<-\EOF && + start 100000 Working hard.......2.........3.........4.........5.........6 progress 100 progress 1000 progress 10000 progress 100000 + stop EOF - test-tool progress --total=100000 \ - "Working hard.......2.........3.........4.........5.........6" \ - <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -89,16 +93,16 @@ Working hard.......2.........3.........4.........5.........6: EOF cat >in <<-\EOF && + start 100000 Working hard.......2.........3.........4.........5.........6 update progress 1 update progress 2 progress 10000 progress 100000 + stop EOF - test-tool progress --total=100000 \ - "Working hard.......2.........3.........4.........5.........6" \ - <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -117,14 +121,14 @@ Working hard.......2.........3.........4.........5.........6: EOF cat >in <<-\EOF && + start 100000 Working hard.......2.........3.........4.........5.........6 progress 25000 progress 50000 progress 75000 progress 100000 + stop EOF - test-tool progress --total=100000 \ - "Working hard.......2.........3.........4.........5.........6" \ - <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -141,14 +145,14 @@ Working hard.......2.........3.........4.........5.........6.........7.........: EOF cat >in <<-\EOF && + start 100000 Working hard.......2.........3.........4.........5.........6.........7......... progress 25000 progress 50000 progress 75000 progress 100000 + stop EOF - test-tool progress --total=100000 \ - "Working hard.......2.........3.........4.........5.........6.........7........." \ - <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -165,12 +169,14 @@ test_expect_success 'progress shortens - crazy caller' ' EOF cat >in <<-\EOF && + start 1000 progress 100 progress 200 progress 1 progress 1000 + stop EOF - test-tool progress --total=1000 "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -186,6 +192,7 @@ test_expect_success 'progress display with throughput' ' EOF cat >in <<-\EOF && + start 0 throughput 102400 1000 update progress 10 @@ -198,8 +205,9 @@ test_expect_success 'progress display with throughput' ' throughput 409600 4000 update progress 40 + stop EOF - test-tool progress "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -215,6 +223,7 @@ test_expect_success 'progress display with throughput and total' ' EOF cat >in <<-\EOF && + start 40 throughput 102400 1000 progress 10 throughput 204800 2000 @@ -223,8 +232,9 @@ test_expect_success 'progress display with throughput and total' ' progress 30 throughput 409600 4000 progress 40 + stop EOF - test-tool progress --total=40 "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -240,6 +250,7 @@ test_expect_success 'cover up after throughput shortens' ' EOF cat >in <<-\EOF && + start 0 throughput 409600 1000 update progress 1 @@ -252,8 +263,9 @@ test_expect_success 'cover up after throughput shortens' ' throughput 1638400 4000 update progress 4 + stop EOF - test-tool progress "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -268,6 +280,7 @@ test_expect_success 'cover up after throughput shortens a lot' ' EOF cat >in <<-\EOF && + start 0 throughput 1 1000 update progress 1 @@ -277,8 +290,9 @@ test_expect_success 'cover up after throughput shortens a lot' ' throughput 3145728 3000 update progress 3 + stop EOF - test-tool progress "Working hard" <in 2>stderr && + test-tool progress <in 2>stderr && show_cr <stderr >out && test_cmp expect out @@ -286,6 +300,7 @@ test_expect_success 'cover up after throughput shortens a lot' ' test_expect_success 'progress generates traces' ' cat >in <<-\EOF && + start 40 throughput 102400 1000 update progress 10 @@ -298,10 +313,11 @@ test_expect_success 'progress generates traces' ' throughput 409600 4000 update progress 40 + stop EOF - GIT_TRACE2_EVENT="$(pwd)/trace.event" test-tool progress --total=40 \ - "Working hard" <in 2>stderr && + GIT_TRACE2_EVENT="$(pwd)/trace.event" test-tool progress \ + <in 2>stderr && # t0212/parse_events.perl intentionally omits regions and data. test_region progress "Working hard" trace.event && From patchwork Thu Feb 3 21:40:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734668 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07A23C433F5 for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243733AbiBCVkn (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:40:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354612AbiBCVkb (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:31 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E269C061401 for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:30 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id n8so3100737wmk.3 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:30 -0800 (PST) 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=nOWIhTHlYqFSATUkwpcKEdTA1tXltlnMcMbJPoO6Fr8=; b=OanROUbC2hb8dAP3fvrRDKMASMMhL3r1GE3KP6y88d8hKSQkRezZZ4u6XIGOGJiIpk DC4tbhmb6J+65uZ4LhK0Z0mXt7BAGQqypw9lZNh2j3jeQaZo9N8M92/LldVeeWp30o/6 o1Mg5/h/X1/gbooyLuS5msXHAnXnDeFi3sz5fuSvBK+qeZ7s49S6L6IWkMhZHyVtH4zx GLTAvZe/32pcbYTDA1BW+0Jyb742xJyDV12e/Vt/ONK+1zFGZAOkSarvs0OOGO87j1SL 4s0EDwWddtH3+OlhbOAU1HcUTO8bnzJXStBgRkpozK6mSj6gps5/B+qm6Vm5BEx5foDF gVWw== 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=nOWIhTHlYqFSATUkwpcKEdTA1tXltlnMcMbJPoO6Fr8=; b=ksxRRAP9dXUkgBiWIT3WL0l5O3vOOa+2nQKr4qE2VDcofniDI7wq5HVr9gYR/Wl6Dt QUPZvKxtQtbfNM66yXi9d0Et/OtIDorAeiK613/WU8Fr0GssV3mYsaOVjA+/M+0vkJj+ XztngYRh5qYnV7Zdrj0TmTcn3LPHMgCWS0KftchEa0xwjeK2OxNo2E/XXkq4Wu6RO9Mf zxeHSuaYtT0QoOQ+Zvj+Qf55hnIUWtd8JT6MfvrvwHLd3roJ/HAS7Mlm23cM+NHDC3Ls ipFEi0IHQCpWYnLOwDtutsxBBRcmOdvPh8U/y/Ynh618HCFKqyYJrz0vhHhZ1ura60pX Hqmg== X-Gm-Message-State: AOAM531MO+/QAekZECZFUYgn+bekPEhS7syf0edNAdQ8Mi+QYLTrJz5d lJCuSaEba8esupMfBIIMXAdU+R/BpeCnBA== X-Google-Smtp-Source: ABdhPJxBIy06+B192XGuVq5qDVHEGKy7/S4LfeAWSQugYPQPrUTCpT6iXhj5blh7MUps+kpoTZ7V0g== X-Received: by 2002:a05:600c:4341:: with SMTP id r1mr12164103wme.99.1643924428634; Thu, 03 Feb 2022 13:40:28 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:27 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 4/9] progress.c tests: test some invalid usage Date: Thu, 3 Feb 2022 22:40:14 +0100 Message-Id: <patch-v9-4.9-965d4ba7b54-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Test what happens when we "stop" without a "start", omit the "stop" after a "start", or start two concurrent progress bars. This extends the trace2 tests added in 98a13647408 (trace2: log progress time and throughput, 2020-05-12). These tests are not merely testing the helper, but invalid API usage that can happen if the progress.c API is misused. The "without stop" test will leak under SANITIZE=leak, since this buggy use of the API will leak memory. But let's not skip it entirely, or use the "!SANITIZE_LEAK" prerequisite check as we'd do with tests that we're skipping due to leaks we haven't fixed yet. Instead annotate the specific command that should skip leak checking with custom $LSAN_OPTIONS[1]. 1. https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- t/t0500-progress-display.sh | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index 27ab4218b01..1eb3a8306ba 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -325,4 +325,54 @@ test_expect_success 'progress generates traces' ' grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event ' +test_expect_success 'progress generates traces: stop / start' ' + cat >in <<-\EOF && + start 0 + stop + EOF + + GIT_TRACE2_EVENT="$PWD/trace-startstop.event" test-tool progress \ + <in 2>stderr && + test_region progress "Working hard" trace-startstop.event +' + +test_expect_success 'progress generates traces: start without stop' ' + cat >in <<-\EOF && + start 0 + EOF + + GIT_TRACE2_EVENT="$PWD/trace-start.event" \ + LSAN_OPTIONS=detect_leaks=0 \ + test-tool progress \ + <in 2>stderr && + grep region_enter.*progress trace-start.event && + ! grep region_leave.*progress trace-start.event +' + +test_expect_success 'progress generates traces: stop without start' ' + cat >in <<-\EOF && + stop + EOF + + GIT_TRACE2_EVENT="$PWD/trace-stop.event" test-tool progress \ + <in 2>stderr && + ! grep region_enter.*progress trace-stop.event && + ! grep region_leave.*progress trace-stop.event +' + +test_expect_success 'progress generates traces: start with active progress bar (no stops)' ' + cat >in <<-\EOF && + start 0 One + start 0 Two + EOF + + GIT_TRACE2_EVENT="$PWD/trace-2start.event" \ + LSAN_OPTIONS=detect_leaks=0 \ + test-tool progress \ + <in 2>stderr && + grep region_enter.*progress.*One trace-2start.event && + grep region_enter.*progress.*Two trace-2start.event && + ! grep region_leave trace-2start.event +' + test_done From patchwork Thu Feb 3 21:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734672 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 548F3C433F5 for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355312AbiBCVme (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:42:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355342AbiBCVki (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:38 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F9A5C061744 for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:31 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id l67-20020a1c2546000000b00353951c3f62so2093611wml.5 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:31 -0800 (PST) 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=gefqGwflQ7jbsXijpDGGG2GnaQZuNBfUSlTXS2fGJpM=; b=dJvB8g0Pv1NDlz0La+qKedxzSGHkBxQ25kybMpBZdoKBHFumhsmq7XRT+aC2NTtJlf gfKsjBwbKuDXIQathEfid2dvUUir7TzZNldlkJdQgAGppFSEjyjVj9YtTTcI3ItmlpAQ C7MYk2f6XjCc5Zk1xEgM44hbpfOzxu5/LFmjKqHF9JffhVZrP3/S3rA/cD6XIaYI29lG gdhBUkiuk0hwcq2uAdr5+8J1L5rEa7pX1D0lMyAH8e3t6Bg5nrSzmxLBf6Xlq/VYLXs9 H0bmQhq5nLKeKLJ8ChiOnQmVaoLaimLbs6FkfP1Vv3Kja7WC7MUV2JJZjHXV4rgz/oQQ QwCw== 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=gefqGwflQ7jbsXijpDGGG2GnaQZuNBfUSlTXS2fGJpM=; b=dc5a9Gj7Rz5yOHYQAZFfNjeQkfQK9RQoJ9xionlo/Ye5u44y5IgYQ1h7IxsYKO0xyx /1C4/MQRCCBX+D1DlF05khkiBdt1Q40MaTz8eCryCPy9APfFtI5Mkm7/YaEWmPf1XiU4 PXQHiVSOqyEnm0o5e5rSElLsyz3ZF9JG4cjPoA369r03TazeRdD+DagamdqexX06eixh 8nc8FjTQGkkzJhZ9NUnDE4/p1MfY4TyZK6fO+Bdn/GRgVsMbvlwXcd0NezqtHTYK9+0E /w4qQAWQ4lzDH+BYaaAON8g5CgoKzcL7YJHMFalntO/RxUDqRInEbdEuKgmRNxyT4tV8 wCuA== X-Gm-Message-State: AOAM531qr08kVcD+iP5WWHljTE5F2a3hM7j00ebZs5iX7/tn0Tly4X+c 6vI0kLsxbgJ9+gaBqCogdxoWXNi7WV2cKw== X-Google-Smtp-Source: ABdhPJxIZ+unsmPw44vIZygDawb5udJq9Q5IFzz6G+nI7pCWwk3GIoTUx2Zj8CY7eCjPoBpaCvpS3A== X-Received: by 2002:a05:600c:1914:: with SMTP id j20mr5162500wmq.51.1643924429567; Thu, 03 Feb 2022 13:40:29 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:28 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 5/9] progress.h: format and be consistent with progress.c naming Date: Thu, 3 Feb 2022 22:40:15 +0100 Message-Id: <patch-v9-5.9-4ab4eb3a20a-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Fix an inconsistency introduced in dc6a0757c4f (make struct progress an opaque type, 2007-10-30) and rename the "progress" parameters to stop_progress{,_msg}() to "p_progress". Now these match the corresponding parameters in the *.c code. While we're at it let's move the definition of the former below the latter, a subsequent change will start defining stop_progress() in terms of stop_progress_msg(). Let's also remove the excess whitespace at the end of the file. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- progress.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/progress.h b/progress.h index f1913acf73f..4f6806904a8 100644 --- a/progress.h +++ b/progress.h @@ -18,7 +18,6 @@ struct progress *start_sparse_progress(const char *title, uint64_t total); struct progress *start_delayed_progress(const char *title, uint64_t total); struct progress *start_delayed_sparse_progress(const char *title, uint64_t total); -void stop_progress(struct progress **progress); -void stop_progress_msg(struct progress **progress, const char *msg); - +void stop_progress_msg(struct progress **p_progress, const char *msg); +void stop_progress(struct progress **p_progress); #endif From patchwork Thu Feb 3 21:40:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734674 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 053B5C4332F for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355387AbiBCVmg (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:42:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355391AbiBCVki (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:38 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9D8C06174A for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:32 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id f80-20020a1c1f53000000b0035399b8bedcso7829599wmf.0 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:32 -0800 (PST) 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=Op9YF+9+OfnrsPN3KXmysjV7ltAH6TWBKYkETUIM3/A=; b=NFgJdE5kO6y8vbO3os9F5nCMno3tDbQ+htLrG501H8nTbjt1DPa8uw/psXVcpvj2wk S7YAnyahmeDeIGb/8iWQPx1GfoXJWpRF6Rw7kISk3bkHwJnjHTYumL2wnJ5gB+BDQhle S0LAqeJ929Hrr6dPFMYQ8NWs1YjyV+DtYZP/QaD1Z/wsFMuULkc3WKad00CZGHFv1oPc lxbhiJWZAf2cKDcfRWWEHhnjXkN44n/qyxfCHqIO1EpS41KHaU3H1BsGqTrLe2AyQyfl efqNGjzFEVPGdhvQ6fIGNBY2SMLn2qbCYN7txdizc8ocJJ7x2/VKCsdqzwIGVL3o03aE dsfA== 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=Op9YF+9+OfnrsPN3KXmysjV7ltAH6TWBKYkETUIM3/A=; b=GKN6PVbXQaIJSRP1TJBdtnLKOGD8f85OJPVgnt3nGiug36250vn3VrcLKal4gq8Pp0 m7IAUoE+bJ8435M6vwZQMC35JphG03UqM/8IVRc1wlEEfj3M8+kv8GSeMZpBi1+35KTj uHhRpm6aG5Jym2aAnf5WCsQ4hdldWD5wNTTHyeqQGRTj+AwV2q907PvOyF+Gki5LjfkU 84bwzxlr7zIdNR3AuRpvNoUIKXUvYmbZL1qCPhYrsSCNCSBbHdxwtsI0JnSRfqhTH5zH K4h3mIdffuVsj+eSHoASgMIC5GLUz9TmmjlQBhIY4iQRBIeEl5ETa6ejhamqV4EjDMqj IFEw== X-Gm-Message-State: AOAM532hcUqvhMWmoxif8mSgNMYMWkfzoMpxNScwh14VyCtp8Zhg2wIE HdtIDIaqWLfpy3zWQAUaflr8C/s1O7ixog== X-Google-Smtp-Source: ABdhPJzVz0OcMGtpkXr3qsecQX6Y0XICpEQnyNcRzIFK9IA/LsMY3zJnGIPP39n4G8/CS02J6V/BAQ== X-Received: by 2002:a05:600c:4ca8:: with SMTP id g40mr12210089wmp.55.1643924430626; Thu, 03 Feb 2022 13:40:30 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:30 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 6/9] progress.c: use dereferenced "progress" variable, not "(*p_progress)" Date: Thu, 3 Feb 2022 22:40:16 +0100 Message-Id: <patch-v9-6.9-ab24cb78d73-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Since 98a13647408 (trace2: log progress time and throughput, 2020-05-12) stop_progress() dereferences a "struct progress **" parameter in several places. Extract a dereferenced variable to reduce clutter and make it clearer who needs to write to this parameter. Now instead of using "*p_progress" several times in stop_progress() we check it once for NULL and then use a dereferenced "progress" variable thereafter. This uses the same pattern as the adjacent stop_progress_msg() function, see ac900fddb7f (progress: don't dereference before checking for NULL, 2020-08-10). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- progress.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/progress.c b/progress.c index 680c6a8bf93..6e7daa3f8a2 100644 --- a/progress.c +++ b/progress.c @@ -319,21 +319,24 @@ static void finish_if_sparse(struct progress *progress) void stop_progress(struct progress **p_progress) { + struct progress *progress; + if (!p_progress) BUG("don't provide NULL to stop_progress"); + progress = *p_progress; - finish_if_sparse(*p_progress); + finish_if_sparse(progress); - if (*p_progress) { + if (progress) { trace2_data_intmax("progress", the_repository, "total_objects", - (*p_progress)->total); + progress->total); - if ((*p_progress)->throughput) + if (progress->throughput) trace2_data_intmax("progress", the_repository, "total_bytes", - (*p_progress)->throughput->curr_total); + progress->throughput->curr_total); - trace2_region_leave("progress", (*p_progress)->title, the_repository); + trace2_region_leave("progress", progress->title, the_repository); } stop_progress_msg(p_progress, _("done")); From patchwork Thu Feb 3 21:40:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734673 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F6D2C433EF for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355351AbiBCVmf (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:42:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355407AbiBCVki (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:38 -0500 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 29223C061753 for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:33 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id j25so6893865wrb.2 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:33 -0800 (PST) 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=pI9ghd36MDsbv1Hq4YR9A3KVEgNU00W0YpjZ51rjAUc=; b=MJqta+91zsab4GKk26FzPs//lq2B/iiOm+8BcKQ68Z+cPj1x8CaLL/erw/uh6ZgpYw pLe/60YrYqKDioGtKR/Bg9mT7TaQRilgWp7LvcZZrCBPlxaESk0bahmEId6VMUd+PYZr FVq7ngRnFL/x2ceruIAlcwyZ+f4h1kduyzifCIO7K8onxkLXxt6guPVghvcn9/vQvoZW fbNQxDcuWjs9YkPge1bLGJAH/UOZdoOliQHxOO7xngMrv/nehokcTovhf/tQB2IgKGXr jwlC4nLaY7GyxqU3Ti7ELV49ZEor/eQcF6ApNgP4ficImlD72AIqIGNMKefvbOqF6hNK 3cXA== 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=pI9ghd36MDsbv1Hq4YR9A3KVEgNU00W0YpjZ51rjAUc=; b=GvIpB9p6mSJcivhiMXszkZdgZCGabHFVyR/e5ff8nIqE8C7Wcy3wBBtzL+AqLKjGCZ tYUa+OA5HyONxS1CaMM7B2UzJz80210GL5caq5PAx9HB9HvlJRxyw4vtVcfpr2yoLsJu uK0FeDLqZZaGlJk6hIA9EwrWCZqu+F2h7n8fJVtey5zqmY/yelxJ5FEW+IS4xqtVnGfa 1lbMpr2CuR978nrFz9wt0MLB5xwc6gto4af9THhFMal9vTG5KrqkgoKgvY/ALaPJuypd PG6HNb3T1axYE0s66AVBuKcZhjrID/lRau77OCMzJ5FEzQ6MJeVXuWt8CvYD0QJ+jsC/ GHDw== X-Gm-Message-State: AOAM533vwwsBhxsRCEEUL2dhb+fCjcX+jZnfz/fmCJ4KzmLuDWU/u9EF 5zqo5quW3sB4404awi0HhFCUduAWxTU6qw== X-Google-Smtp-Source: ABdhPJxSMnnzMligWO533lFigRSNNGQDWv9K/2xxsSZDgJjB7dYn5zyuKJxXKmho3pu7hhWlTaxZMw== X-Received: by 2002:a5d:67cd:: with SMTP id n13mr31378074wrw.351.1643924431543; Thu, 03 Feb 2022 13:40:31 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:30 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 7/9] progress.c: refactor stop_progress{,_msg}() to use helpers Date: Thu, 3 Feb 2022 22:40:17 +0100 Message-Id: <patch-v9-7.9-3406d71b499-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Create two new static helpers for the stop_progress() and stop_progress_msg() functions. As we'll see in the subsequent commit having those two split up doesn't make much sense, and results in a bug in how we log to trace2. This narrow preparatory change makes the diff for that subsequent change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- progress.c | 64 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/progress.c b/progress.c index 6e7daa3f8a2..6cc7f902f5e 100644 --- a/progress.c +++ b/progress.c @@ -317,6 +317,36 @@ static void finish_if_sparse(struct progress *progress) display_progress(progress, progress->total); } +static void force_last_update(struct progress *progress, const char *msg) +{ + char *buf; + struct throughput *tp = progress->throughput; + + if (tp) { + uint64_t now_ns = progress_getnanotime(progress); + unsigned int misecs, rate; + misecs = ((now_ns - progress->start_ns) * 4398) >> 32; + rate = tp->curr_total / (misecs ? misecs : 1); + throughput_string(&tp->display, tp->curr_total, rate); + } + progress_update = 1; + buf = xstrfmt(", %s.\n", msg); + display(progress, progress->last_value, buf); + free(buf); +} + +static void log_trace2(struct progress *progress) +{ + trace2_data_intmax("progress", the_repository, "total_objects", + progress->total); + + if (progress->throughput) + trace2_data_intmax("progress", the_repository, "total_bytes", + progress->throughput->curr_total); + + trace2_region_leave("progress", progress->title, the_repository); +} + void stop_progress(struct progress **p_progress) { struct progress *progress; @@ -327,17 +357,8 @@ void stop_progress(struct progress **p_progress) finish_if_sparse(progress); - if (progress) { - trace2_data_intmax("progress", the_repository, "total_objects", - progress->total); - - if (progress->throughput) - trace2_data_intmax("progress", the_repository, - "total_bytes", - progress->throughput->curr_total); - - trace2_region_leave("progress", progress->title, the_repository); - } + if (progress) + log_trace2(*p_progress); stop_progress_msg(p_progress, _("done")); } @@ -353,23 +374,10 @@ void stop_progress_msg(struct progress **p_progress, const char *msg) if (!progress) return; *p_progress = NULL; - if (progress->last_value != -1) { - /* Force the last update */ - char *buf; - struct throughput *tp = progress->throughput; - - if (tp) { - uint64_t now_ns = progress_getnanotime(progress); - unsigned int misecs, rate; - misecs = ((now_ns - progress->start_ns) * 4398) >> 32; - rate = tp->curr_total / (misecs ? misecs : 1); - throughput_string(&tp->display, tp->curr_total, rate); - } - progress_update = 1; - buf = xstrfmt(", %s.\n", msg); - display(progress, progress->last_value, buf); - free(buf); - } + + if (progress->last_value != -1) + force_last_update(progress, msg); + clear_progress_signal(); strbuf_release(&progress->counters_sb); if (progress->throughput) From patchwork Thu Feb 3 21:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734669 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0189DC433EF for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355186AbiBCVko (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355412AbiBCVki (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:38 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314B0C061757 for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:34 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id v123so3117002wme.2 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:34 -0800 (PST) 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=PYWUjE4UOevYyYTpr7vP5excF6CF1ZbFF51GkfF5dWg=; b=WTIztLlg4Mwpjb2UNkHSa0UPU6UUk/XyYnh8ZaaxVTmffUTVsiZy0kFa7ezPNGWUj6 OCU3U+0OwKvn1D5Wts7cInyKcXZ8qSQwHvCr6DPrt8Z7hGjHWEUdly9HbPLEupG41wN6 QruviM5dBa25ZAROgMoX3ucPCNyLsL4OKWcdswY8vBTEjT86nbqgzrb0iGQudYEuhW2V s+JSf37RcmZ90Zw6nX9D0H6VPH4IpBL+7iiPJzKCGpdQHApi0xvWufIo5AwTgdORaCTP PtN74c5eAGTW1fO2MTM9iZlJBYtRHrrrt1kvFR5ZQwm0O0qjjX+YUPR/rTFLfVmaAKOH 1grg== 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=PYWUjE4UOevYyYTpr7vP5excF6CF1ZbFF51GkfF5dWg=; b=ykkt2i2fy/DtSgTvQy9S3AH1sBGJT7Okj4hfv9EPs9nbV6Kl0HOV/SGFIDLvA+cZfY 28+iDSW90Zhbv4GHXkV0AyNqXuYtrVwrvqwHFLYoHko1Nco6LbH5p76JRfAfrqH7iaH7 Y4cxhM05HBnUNGZc3nQUYppIcVKyR4qJ7Ul2Xq8EWyDmkc3W6O87zxzTxjr/PvQFLqN9 bl2Bva1Yg/eaf+p6gZMF5s4Dw0vnPBMIxorxidM7kS0j/szOfl4BkGSisflVEL6fAmf0 te/w81oPtBdKF97sPXy65lYNW55jPElRwknHZdS/Wcca/V+bDm4AEsM2JIEuspT4x7Qp vYXw== X-Gm-Message-State: AOAM5301MQKodK5SP1saO3X3L7QdxbZYovTsXtPFsGYwcpo5aD86SDcL yfvPjoOjv9DdZEI62+jPXThb1l7o2lkBZQ== X-Google-Smtp-Source: ABdhPJwKG+FBhdhb9gxsJ4o1z+jSefnQQQE9wureRe6p6axAe4VrJKw/iP2wwbT/u3iuc9HXIwrwMg== X-Received: by 2002:a05:600c:600f:: with SMTP id az15mr12115231wmb.27.1643924432575; Thu, 03 Feb 2022 13:40:32 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:31 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 8/9] progress API: unify stop_progress{,_msg}(), fix trace2 bug Date: Thu, 3 Feb 2022 22:40:18 +0100 Message-Id: <patch-v9-8.9-62a93bb98b0-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Fix a bug that's been with us ever since 98a13647408 (trace2: log progress time and throughput, 2020-05-12), when the stop_progress_msg() API was used we didn't log a "region_leave" for the "region_enter" we start in "start_progress_delay()". The only user of the "stop_progress_msg()" function is "index-pack". Let's add a previously failing test to check that we have the same number of "region_enter" and "region_leave" events, with "-v" we'll log progress even in the test environment. In addition to that we've had a submarine bug here introduced with 9d81ecb52b5 (progress: add sparse mode to force 100% complete message, 2019-03-21). The "start_sparse_progress()" API would only do the right thing if the progress was ended with "stop_progress()", not "stop_progress_msg()". The only user of that API uses "stop_progress()", but let's still fix that along with the trace2 issue by making "stop_progress()" a trivial wrapper for "stop_progress_msg()". We can also drop the "if (progress)" test from "finish_if_sparse()". It's now a helper for the small "stop_progress_msg()" function. We'll already have returned from it if "progress" is "NULL". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- progress.c | 21 +++------------------ progress.h | 6 +++++- t/t5316-pack-delta-depth.sh | 6 +++++- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/progress.c b/progress.c index 6cc7f902f5e..0cdd875d37f 100644 --- a/progress.c +++ b/progress.c @@ -311,8 +311,7 @@ struct progress *start_delayed_sparse_progress(const char *title, static void finish_if_sparse(struct progress *progress) { - if (progress && - progress->sparse && + if (progress->sparse && progress->last_value != progress->total) display_progress(progress, progress->total); } @@ -347,22 +346,6 @@ static void log_trace2(struct progress *progress) trace2_region_leave("progress", progress->title, the_repository); } -void stop_progress(struct progress **p_progress) -{ - struct progress *progress; - - if (!p_progress) - BUG("don't provide NULL to stop_progress"); - progress = *p_progress; - - finish_if_sparse(progress); - - if (progress) - log_trace2(*p_progress); - - stop_progress_msg(p_progress, _("done")); -} - void stop_progress_msg(struct progress **p_progress, const char *msg) { struct progress *progress; @@ -375,8 +358,10 @@ void stop_progress_msg(struct progress **p_progress, const char *msg) return; *p_progress = NULL; + finish_if_sparse(progress); if (progress->last_value != -1) force_last_update(progress, msg); + log_trace2(progress); clear_progress_signal(); strbuf_release(&progress->counters_sb); diff --git a/progress.h b/progress.h index 4f6806904a8..3a945637c81 100644 --- a/progress.h +++ b/progress.h @@ -1,5 +1,6 @@ #ifndef PROGRESS_H #define PROGRESS_H +#include "gettext.h" struct progress; @@ -19,5 +20,8 @@ struct progress *start_delayed_progress(const char *title, uint64_t total); struct progress *start_delayed_sparse_progress(const char *title, uint64_t total); void stop_progress_msg(struct progress **p_progress, const char *msg); -void stop_progress(struct progress **p_progress); +static inline void stop_progress(struct progress **p_progress) +{ + stop_progress_msg(p_progress, _("done")); +} #endif diff --git a/t/t5316-pack-delta-depth.sh b/t/t5316-pack-delta-depth.sh index df524f7b6dd..e9045009a11 100755 --- a/t/t5316-pack-delta-depth.sh +++ b/t/t5316-pack-delta-depth.sh @@ -64,7 +64,11 @@ test_expect_success 'create series of packs' ' echo $cur && echo "$(git rev-parse :file) file" } | git pack-objects --stdout >tmp && - git index-pack --stdin --fix-thin <tmp || return 1 + GIT_TRACE2_EVENT=$PWD/trace \ + git index-pack -v --stdin --fix-thin <tmp || return 1 && + grep -c region_enter.*progress trace >enter && + grep -c region_leave.*progress trace >leave && + test_cmp enter leave && prev=$cur done ' From patchwork Thu Feb 3 21:40:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> X-Patchwork-Id: 12734670 Return-Path: <git-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E846AC433FE for <git@archiver.kernel.org>; Thu, 3 Feb 2022 21:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355228AbiBCVkp (ORCPT <rfc822;git@archiver.kernel.org>); Thu, 3 Feb 2022 16:40:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355419AbiBCVki (ORCPT <rfc822;git@vger.kernel.org>); Thu, 3 Feb 2022 16:40:38 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E5E8C061759 for <git@vger.kernel.org>; Thu, 3 Feb 2022 13:40:35 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id g18so7240962wrb.6 for <git@vger.kernel.org>; Thu, 03 Feb 2022 13:40:35 -0800 (PST) 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=cfw4kS5PHnzrHd+0EMmKzUmCahqYjc0DYdcrj/gIj5M=; b=MktiEuo2Y10jJ+a1eRLAYeVFHDZUQZBkCxsPTSZuPA7tPjoVIJBTuJigNkYbCAaWfE 50QUkozAosqS4GtGG5yFnRkV2RrgJkLu5kZSGg6qlc4OuVEpHTseaJ6pdnUgu9lW6xOJ 1497+FbbsfjFJwU7CB2/rqoSqePcXn9W0cJp1pQ4NFm7BaLACXSvbez6dm2bVJ5vhJ6g Lb1jYVW7lLzvErMU+MkxJqBWS5e3pWMvMcQRPLRvPEzVWxcBP22SdX+16A87j9xbFB3C zA1qKFLIP+GqlPfUuo6o7DWNooVkg/9SJ1VxvI0SVyvLMucEMJd1kOs5DFkKrZcZ0UK1 tusw== 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=cfw4kS5PHnzrHd+0EMmKzUmCahqYjc0DYdcrj/gIj5M=; b=W6/kj4o3qsAFy/aqTIdSfO2IV2ZRZxQ5L+9ChpSqv5WSVdDyz8cXl5VFkz4th1beqT OQezmmyY3Dl1DO1YpmWpdk8TTts19jgYPsIjwgalF2yW7Xadudp1KS9ed8KMu7Sa+ubc MexUVlQwH0iAB6ohOps0hZV/PYJediK/g+5vw2LJhgS/Mc2yzMr8fifjdggKc5CUkq14 xwGZaoNr5ZwkiLmgywlsWlfgmDsbzvkOHy/JdB9d+x834eSnt4arF22mfcf4AT02+VcH JizHDQPDXhOeIjQ8QkTs7pHSBRGlzYg5bon4whDmbu2iBmVNjvhakEL0ikUa+v4lrrsi awVw== X-Gm-Message-State: AOAM533cYjmLaBEknZXkwek9/SjdeaJ2LmWI/X5c8TCpQMth/qHVkzTH dIHPaah0a4pYD8FCAPTxuw3kreR1A+B0Uw== X-Google-Smtp-Source: ABdhPJwUFzxbyZWgjlZ1oQ6s8exlEZsUHkG4Lkn9+Hp2mHyLkMsad9OK0Jdka7vgsL0159n/fnavyw== X-Received: by 2002:a5d:43c2:: with SMTP id v2mr4525467wrr.455.1643924433494; Thu, 03 Feb 2022 13:40:33 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13sm10637wrf.3.2022.02.03.13.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 13:40:32 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= <avarab@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, =?utf-8?q?SZEDER_G=C3=A1bor?= <szeder.dev@gmail.com>, =?utf-8?q?Ren=C3=A9_S?= =?utf-8?q?charfe?= <l.s.r@web.de>, Johannes Altmanninger <aclopte@gmail.com>, Emily Shaffer <emilyshaffer@google.com>, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= <avarab@gmail.com> Subject: [PATCH v9 9/9] pack-bitmap-write.c: don't return without stop_progress() Date: Thu, 3 Feb 2022 22:40:19 +0100 Message-Id: <patch-v9-9.9-0b2248a2d74-20220203T213350Z-avarab@gmail.com> X-Mailer: git-send-email 2.35.1.939.g42bf83caa3d In-Reply-To: <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> References: <cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com> <cover-v9-0.9-00000000000-20220203T213350Z-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Fix a bug that's been here since 7cc8f971085 (pack-objects: implement bitmap writing, 2013-12-21), we did not call stop_progress() if we reached the early exit in this function. We could call stop_progress() before we return, but better yet is to defer calling start_progress() until we need it. For now this only matters in practice because we'd previously omit the "region_leave" for the progress trace2 event. Suggested-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- pack-bitmap-write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 9c55c1531e1..cab3eaa2acd 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -575,15 +575,15 @@ void bitmap_writer_select_commits(struct commit **indexed_commits, QSORT(indexed_commits, indexed_commits_nr, date_compare); - if (writer.show_progress) - writer.progress = start_progress("Selecting bitmap commits", 0); - if (indexed_commits_nr < 100) { for (i = 0; i < indexed_commits_nr; ++i) push_bitmapped_commit(indexed_commits[i]); return; } + if (writer.show_progress) + writer.progress = start_progress("Selecting bitmap commits", 0); + for (;;) { struct commit *chosen = NULL;