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

Re: [RFC PATCH v2 1/4] builtin/rebase.c: reuse loop variable

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 21, 2019, 01:30 UTC
Message-ID
<xmqqmucq9ftj.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191120095238.4349-2-rybak.a.v@gmail.com>
Andrei Rybak <rybak.a.v@gmail.com> writes:
> Variable "int i" is already defined at the top of the function
> cmd_rebase, so reuse it instead of declaring other variables, which mask
> the outer "i".

The log message must also mention the other reason why this simplification is correct, namely, that outer "i" is dead at the point in the code that is touched by this patch and the value is never used in the later parts of the code (I just followed the codepath and made sure that is the case---iow, I think this patch is correct).

Thanks.
Show 27 quoted lines
>
> Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
> ---
>  builtin/rebase.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 4a20582e72..793cac1386 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -1747,8 +1747,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	if (exec.nr) {
> -		int i;
> -
>  		imply_interactive(&options, "--exec");
>  
>  		strbuf_reset(&buf);
> @@ -1769,8 +1767,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	if (strategy_options.nr) {
> -		int i;
> -
>  		if (!options.strategy)
>  			options.strategy = "recursive";
Previous: Andrei RybakNext: Andrei Rybak
Message 7 of 13 in “rebase --edit-todo --exec”
  1. 0/3 rebase --edit-todo --execAndrei Rybak, Nov 14, 2019
  2. 1/3 rebase: prepare cmd before choosing actionAndrei Rybak, Nov 14, 2019
  3. Junio C HamanoNov 15, 2019
  4. 2/3 rebase: extract add_exec()Andrei Rybak, Nov 14, 2019
  5. 3/3 rebase -i: allow --edit-todo with --execAndrei Rybak, Nov 14, 2019
  6. 1/4 builtin/rebase.c: reuse loop variableAndrei Rybak, Nov 20, 2019
  7. Junio C HamanoNov 21, 2019
  8. 2/4 rebase: prepare cmd before choosing actionAndrei Rybak, Nov 20, 2019
  9. Junio C HamanoNov 21, 2019
  10. Andrei RybakNov 22, 2019
  11. 0/4 rebase --edit-todo --execAndrei Rybak, Nov 20, 2019
  12. 3/4 rebase: extract add_exec()Andrei Rybak, Nov 20, 2019
  13. 4/4 rebase -i: allow --edit-todo with --execAndrei Rybak, Nov 20, 2019

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.