All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Derrick Stolee <derrickstolee@github.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] commit-graph: increment progress indicator
Date: Wed, 12 Jun 2024 09:14:47 +0200	[thread overview]
Message-ID: <ZmlK59HYWY_aXgv5@tanuki> (raw)
In-Reply-To: <pull.1743.git.1718118555197.gitgitgadget@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3031 bytes --]

On Tue, Jun 11, 2024 at 03:09:15PM +0000, Johannes Schindelin via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
> 
> This fixes a bug that was introduced by 368d19b0b7 (commit-graph:
> refactor compute_topological_levels(), 2023-03-20): Previously, the
> progress indicator was updated from `i + 1` where `i` is the loop
> variable of the enclosing `for` loop. After this patch, the update used
> `info->progress_cnt + 1` instead, however, unlike `i`, the
> `progress_cnt` attribute was not incremented. Let's increment it.
> 
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>     commit-graph: fix a progress indicator bug
>     
>     Stolee noticed this bug when integrating the for-each-ref --ahead-behind
>     patches into GitHub's internal fork of Git, and fixed it. For a variety
>     of reasons, upstreaming this fix fell between the cracks. Until now.
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1743%2Fdscho%2Fincrement-progress-in-commit-graph-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1743/dscho/increment-progress-in-commit-graph-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1743
> 
>  commit-graph.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/commit-graph.c b/commit-graph.c
> index e5dd3553dfe..41a2e1b4c6d 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -1597,7 +1597,7 @@ static void compute_reachable_generation_numbers(
>  		timestamp_t gen;
>  		repo_parse_commit(info->r, c);
>  		gen = info->get_generation(c, info->data);
> -		display_progress(info->progress, info->progress_cnt + 1);
> +		display_progress(info->progress, ++info->progress_cnt);
>  
>  		if (gen != GENERATION_NUMBER_ZERO && gen != GENERATION_NUMBER_INFINITY)
>  			continue;

The fix looks obviously correct. Do we also want to amend tests? We have
e.g. "t6500-gc.sh", "gc --no-quiet", where we already grep for the
progress report without verifying numbers. The output there is:

    Computing commit graph topological levels:  25% (1/4), done.
    Computing commit graph generation numbers:  25% (1/4), done.

, which clearly demonstrates the bug for both callsites of the buggy
function.

The following change would thus detect such regressions in the future:

    diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
    index 43d40175f8..1b5909d1b7 100755
    --- a/t/t6500-gc.sh
    +++ b/t/t6500-gc.sh
    @@ -158,7 +158,7 @@ test_expect_success TTY 'with TTY: gc --no-quiet' '
            git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
        test_must_be_empty stdout &&
        test_grep "Enumerating objects" stderr &&
    -	test_grep "Computing commit graph generation numbers" stderr
    +	test_grep "Computing commit graph generation numbers: 100% (4/4), done." stderr
     '
     
     test_expect_success 'gc --quiet' '

Patrick

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-06-12  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 15:09 [PATCH] commit-graph: increment progress indicator Johannes Schindelin via GitGitGadget
2024-06-12  7:14 ` Patrick Steinhardt [this message]
2024-06-12  8:26   ` Johannes Schindelin
2024-06-12 14:43 ` Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZmlK59HYWY_aXgv5@tanuki \
    --to=ps@pks.im \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.