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

Re: [PATCH 1/1] git-gui: remove unused global declarations

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 25, 2019, 03:54 UTC
Message-ID
<xmqq1rv1eaz1.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191025013255.7367-2-me@yadavpratyush.com>
Pratyush Yadav <me@yadavpratyush.com> writes:
Show 5 quoted lines
>  proc next_diff {{after {}}} {
> -	global next_diff_p next_diff_w next_diff_i
> +	global next_diff_p next_diff_w
>  	show_diff $next_diff_p $next_diff_w {} {} $after
>  }

Not in particular about next_diff_i, but seeing a hunk like this makes me wonder if you want to go the other way around. If a future fix needs to (re)introduce the use of next_diff_i global variable in this proc (it seems that there are two procs that declare the variable as global, one of which is this one, and the other one assigns to it), the code change must resurrect this declaration; otherwise the code would only confuse itself by potentially having two variables (one global, one local) with the same name, no?

For next_diff_i in particular, I think the right solution would be to remove both global decl and the assignment, as the assignment is made to otherwise unused variable. But the primary point in such a change is not "remove unused global decl"; it is "remove unused variable".

Previous: Pratyush YadavNext: Pratyush Yadav
Message 3 of 6 in “git-gui: remove unused global declarations”
  1. 0/1 git-gui: remove unused global declarationsPratyush Yadav, Oct 25, 2019
  2. 1/1 git-gui: remove unused global declarationsPratyush Yadav, Oct 25, 2019
  3. Junio C HamanoOct 25, 2019
  4. Pratyush YadavOct 29, 2019
  5. Johannes SchindelinOct 28, 2019
  6. Pratyush YadavOct 29, 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.