git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] progress: remove redundant null-checking

From
Derrick Stolee <stolee@gmail.com>
Date
Jul 10, 2020, 02:01 UTC
Message-ID
<aebbc1ca-9936-ce1b-bacc-855d353f83f9@gmail.com>
In-Reply-To
<20200710014242.1088216-3-emilyshaffer@google.com>
On 7/9/2020 9:42 PM, Emily Shaffer wrote:
Show 65 quoted lines
> display_progress() and stop_progress() are tolerant to NULL inputs.
> Remove some places where redundant checks are performed before these
> NULL-tolerant functions are called.
> 
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
>  builtin/commit-graph.c | 3 +--
>  commit-graph.c         | 3 +--
>  read-cache.c           | 9 +++------
>  3 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
> index ae4dc2dfcd..7964de3126 100644
> --- a/builtin/commit-graph.c
> +++ b/builtin/commit-graph.c
> @@ -263,8 +263,7 @@ static int graph_write(int argc, const char **argv)
>  cleanup:
>  	string_list_clear(&pack_indexes, 0);
>  	strbuf_release(&buf);
> -	if (progress)
> -		stop_progress(&progress);
> +	stop_progress(&progress);
>  	return result;
>  }
>  
> diff --git a/commit-graph.c b/commit-graph.c
> index b9a784fece..30d9a75932 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -1424,8 +1424,7 @@ int write_commit_graph_reachable(struct object_directory *odb,
>  				    flags, split_opts);
>  
>  	oidset_clear(&commits);
> -	if (data.progress)
> -		stop_progress(&data.progress);
> +	stop_progress(&data.progress);
>  	return result;
>  }
>  
> diff --git a/read-cache.c b/read-cache.c
> index 2ddc422dbd..feb7abe37a 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1581,8 +1581,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
>  		new_entry = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);
>  		if (new_entry == ce)
>  			continue;
> -		if (progress)
> -			display_progress(progress, i);
> +		display_progress(progress, i);
>  		if (!new_entry) {
>  			const char *fmt;
>  
> @@ -1614,10 +1613,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
>  
>  		replace_index_entry(istate, i, new_entry);
>  	}
> -	if (progress) {
> -		display_progress(progress, istate->cache_nr);
> -		stop_progress(&progress);
> -	}
> +	display_progress(progress, istate->cache_nr);
> +	stop_progress(&progress);
>  	trace_performance_leave("refresh index");
>  	return has_errors;
Looks obviously correct to me.

Thanks, -Stolee

Previous: Emily ShafferNext: Taylor Blau
Message 21 of 27 in “enable progress traces even when quiet”
  1. 0/2 enable progress traces even when quietEmily Shaffer, Jul 10, 2020
  2. 1/2 progress: create progress struct in 'verbose' modeEmily Shaffer, Jul 10, 2020
  3. Derrick StoleeJul 10, 2020
  4. Taylor BlauJul 10, 2020
  5. Emily ShafferJul 10, 2020
  6. brian m. carlsonJul 10, 2020
  7. Emily ShafferJul 10, 2020
  8. Junio C HamanoJul 10, 2020
  9. Emily ShafferJul 10, 2020
  10. Junio C HamanoJul 10, 2020
  11. Emily ShafferJul 14, 2020
  12. Emily ShafferAug 17, 2020
  13. Junio C HamanoAug 17, 2020
  14. Junio C HamanoAug 17, 2020
  15. Jonathan TanSep 9, 2020
  16. Jonathan TanSep 9, 2020
  17. Junio C HamanoSep 9, 2020
  18. Jonathan NiederSep 10, 2020
  19. Junio C HamanoSep 10, 2020
  20. 2/2 progress: remove redundant null-checkingEmily Shaffer, Jul 10, 2020
  21. Derrick StoleeJul 10, 2020
  22. Taylor BlauJul 10, 2020
  23. Junio C HamanoJul 10, 2020
  24. Emily ShafferJul 10, 2020
  25. Junio C HamanoJul 10, 2020
  26. Emily ShafferJul 10, 2020
  27. Emily ShafferJul 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.