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

[PATCH v1 0/6] globals: clean up some global usages

From
Ben Boeckel <mathstuf@gmail.com>
Date
Jul 31, 2021, 02:42 UTC
Message-ID
<20210731024221.2113906-1-mathstuf@gmail.com>
Hi,

This patchset moves a few of the configuration parsing functions around so that they live in the source file which uses the variables that are initialized through those functions. This allows the variables involved to be `static` rather than global variables.

Additionally, a global which is only written to is removed (`core_compression_level`), a file-local variable declared `extern` is now `static`, and explicit `0` initialization of globals is removed.

In the course of making this patch, I found a number of other global variables which could be moved into being static if more configuration parsing functions were created and moved to the relevant file instead of being parsed as part of, say, "all `core.*` settings" in a single function. If wanted, I can prepare a patchset for these as well (or provide the list for discussion of how best to proceed, but it is currently just stored in a WIP commit I have locally as comments on each variable).

Thanks,
--Ben
---
Ben Boeckel (6):
  branch: move `git_default_branch_config` to `branch.c`
  mailmap: move `git_default_mailmap_config` to `mailmap.c`
  apply: move `apply_default_*whitespace` to `apply.c`
  config: remove `core_compression_level`
  refs/debug: declare file-local variable to be static
  globals: remove explicit `0` initialization from globals
 apply.c       |  3 +++
 branch.c      | 32 ++++++++++++++++++++++++++++++++
 branch.h      |  5 +++++
 cache.h       |  6 ------
 config.c      | 43 +------------------------------------------
 environment.c |  4 ----
 mailmap.c     | 16 ++++++++++++++--
 mailmap.h     |  2 ++
 object-file.c |  2 +-
 progress.c    |  2 +-
 refs/debug.c  |  4 ++--
 11 files changed, 61 insertions(+), 58 deletions(-)
base-commit: eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687
-- 
2.31.1
Next: Ben Boeckel
Message 1 of 7 in “globals: clean up some global usages”
  1. 0/6 globals: clean up some global usagesBen Boeckel, Jul 31, 2021
  2. 1/6 branch: move `git_default_branch_config` to `branch.c`Ben Boeckel, Jul 31, 2021
  3. 3/6 apply: move `apply_default_*whitespace` to `apply.c`Ben Boeckel, Jul 31, 2021
  4. 2/6 mailmap: move `git_default_mailmap_config` to `mailmap.c`Ben Boeckel, Jul 31, 2021
  5. 4/6 config: remove `core_compression_level`Ben Boeckel, Jul 31, 2021
  6. 5/6 refs/debug: declare file-local variable to be staticBen Boeckel, Jul 31, 2021
  7. 6/6 globals: remove explicit `0` initialization from globalsBen Boeckel, Jul 31, 2021

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.