Skip to content

globals: clean up some global usages

Ben Boeckel git 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6branch: move `git_default_branch_config` to `branch.c`branch.c branch.h cache.h +2 more+37 -320 replies
2/6mailmap: move `git_default_mailmap_config` to `mailmap.c`cache.h config.c mailmap.c +1 more+17 -150 replies
3/6apply: move `apply_default_*whitespace` to `apply.c`apply.c cache.h environment.c+3 -40 replies
4/6config: remove `core_compression_level`cache.h config.c environment.c+0 -30 replies
5/6refs/debug: declare file-local variable to be staticrefs/debug.c+2 -20 replies
6/6globals: remove explicit `0` initialization from globalsobject-file.c progress.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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

Signature · 1 line
2.31.1