Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository()
From: Junio C Hamano <hidden>
Date: 2026-08-27 19:09:23
Hardik Kumar [off-list ref] writes:
The patch leaves some instances of this case that would require additional changes rather than simply replacing the arguments passed to the function call. - Only update sites that do not introduce any functional changes.
How did you make sure that the places touched by this patch do not? How do you deal with repo==NULL case in these code paths?
quoted hunk ↗ jump to hunk
- `UNUSED` is dropped from `*repo` parameter to match the changes. Signed-off-by: Hardik Kumar <redacted> --- builtin/blame.c | 4 ++-- builtin/gc.c | 4 ++-- builtin/repo.c | 4 ++-- builtin/reset.c | 4 ++-- transport.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-)diff --git a/builtin/blame.c b/builtin/blame.c index 48d5251c6d..dbf4b4ffc7 100644 --- a/builtin/blame.c +++ b/builtin/blame.c@@ -957,7 +957,7 @@ static void build_ignorelist(struct blame_scoreboard *sb, int cmd_blame(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { struct rev_info revs; char *path = NULL;@@ -1187,7 +1187,7 @@ int cmd_blame(int argc, revs.disable_stdin = 1; setup_revisions(argc, argv, &revs, NULL); - if (!revs.pending.nr && is_bare_repository(the_repository)) { + if (!revs.pending.nr && is_bare_repository(repo)) { struct commit *head_commit; struct object_id head_oid;diff --git a/builtin/gc.c b/builtin/gc.c index de2f9e7fed..8e82cce86b 100644 --- a/builtin/gc.c +++ b/builtin/gc.c@@ -582,7 +582,7 @@ static int maintenance_task_odb(struct maintenance_run_opts *opts, int cmd_gc(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int aggressive = 0; int force = 0;@@ -637,7 +637,7 @@ int cmd_gc(int argc, die(_("failed to parse gc.logExpiry value %s"), cfg.gc_log_expire); if (cfg.pack_refs < 0) - cfg.pack_refs = !is_bare_repository(the_repository); + cfg.pack_refs = !is_bare_repository(repo); argc = parse_options(argc, argv, prefix, builtin_gc_options, builtin_gc_usage, 0);diff --git a/builtin/repo.c b/builtin/repo.c index 84e012f83f..0bf3c0a475 100644 --- a/builtin/repo.c +++ b/builtin/repo.c@@ -58,9 +58,9 @@ struct repo_info_field { get_value_fn *get_value; }; -static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf) +static int get_layout_bare(struct repository *repo, struct strbuf *buf) { - strbuf_addstr(buf, is_bare_repository(the_repository) ? "true" : "false"); + strbuf_addstr(buf, is_bare_repository(repo) ? "true" : "false"); return 0; }diff --git a/builtin/reset.c b/builtin/reset.c index 78e69bd84b..e029b7e99a 100644 --- a/builtin/reset.c +++ b/builtin/reset.c@@ -336,7 +336,7 @@ static int git_reset_config(const char *var, const char *value, int cmd_reset(int argc, const char **argv, const char *prefix, - struct repository *repo UNUSED) + struct repository *repo) { int reset_type = NONE, update_ref_status = 0, quiet = 0; int no_refresh = 0;@@ -470,7 +470,7 @@ int cmd_reset(int argc, if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository))) setup_work_tree(the_repository); - if (reset_type == MIXED && is_bare_repository(the_repository)) + if (reset_type == MIXED && is_bare_repository(repo)) die(_("%s reset is not allowed in a bare repository"), _(reset_type_names[reset_type]));diff --git a/transport.c b/transport.c index 25e2c14a7b..82eea3024b 100644 --- a/transport.c +++ b/transport.c@@ -1528,7 +1528,7 @@ int transport_push(struct repository *r, if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND | TRANSPORT_RECURSE_SUBMODULES_ONLY)) && - !is_bare_repository(the_repository)) { + !is_bare_repository(r)) { struct ref *ref = remote_refs; struct oid_array commits = OID_ARRAY_INIT;@@ -1555,7 +1555,7 @@ int transport_push(struct repository *r, if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) || ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND | TRANSPORT_RECURSE_SUBMODULES_ONLY)) && - !pretend)) && !is_bare_repository(the_repository)) { + !pretend)) && !is_bare_repository(r)) { struct ref *ref = remote_refs; struct string_list needs_pushing = STRING_LIST_INIT_DUP; struct oid_array commits = OID_ARRAY_INIT;--- base-commit: f78ce2f7b6df702f93d40b85d6bda92a3f65da79 change-id: 20260827-env-is_bare_repo-564917c2d3ab