All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] builtin: replace the_repository parameter in is_bare_repository()
@ 2026-08-27 18:29 Hardik Kumar
  2026-08-27 19:09 ` Junio C Hamano
  0 siblings, 1 reply; 28+ messages in thread
From: Hardik Kumar @ 2026-08-27 18:29 UTC (permalink / raw)
  To: git; +Cc: Hardik Kumar

Many functions receive a `struct repository *repo` parameter but do not
use it (marked UNUSED) and instead pass the global `the_repository`
parameter to the `is_bare_repository()` function.

Replace the argument passed to `is_bare_repository()` from the global
`the_repository` parameter to take the unused repository parameter so
that we no longer depend on `the_repository`. Patch covers the sites
that were not updated previously.

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.
- `UNUSED` is dropped from `*repo` parameter to match the changes.

Signed-off-by: Hardik Kumar <hardikxk@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-08-29 13:24 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27 18:29 [PATCH] builtin: replace the_repository parameter in is_bare_repository() Hardik Kumar
2026-08-27 19:09 ` Junio C Hamano
2026-08-27 19:51   ` Junio C Hamano
2026-08-27 20:09     ` Hardik Kumar
2026-08-27 20:28       ` Junio C Hamano
2026-08-27 21:12         ` Ben Knoble
2026-08-27 21:39           ` Junio C Hamano
2026-08-28 11:41             ` D. Ben Knoble
2026-08-28 22:51               ` Junio C Hamano
2026-08-28 22:51                 ` [PATCH 0/8] More sensible checkout/switch/restore code refactoring Junio C Hamano
2026-08-28 22:51                   ` [PATCH 1/8] checkout: pass cb_option explicitly to branch name parsers Junio C Hamano
2026-08-28 22:52                   ` [PATCH 2/8] checkout: validate new branch name in checkout_branch() Junio C Hamano
2026-08-28 22:52                   ` [PATCH 3/8] checkout: validate stage and merge option compatibility in checkout_paths() Junio C Hamano
2026-08-28 22:52                   ` [PATCH 4/8] checkout: extract option validation and pathspec helpers Junio C Hamano
2026-08-28 22:52                   ` [PATCH 5/8] checkout: extract branch setup and tracking helpers Junio C Hamano
2026-08-28 22:52                   ` [PATCH 6/8] checkout: restructure switch, restore, and checkout entrypoints Junio C Hamano
2026-08-28 22:52                   ` [PATCH 7/8] checkout: wrap overly long lines Junio C Hamano
2026-08-28 22:55                     ` Junio C Hamano
2026-08-29  2:06                       ` Junio C Hamano
2026-08-28 22:52                   ` [PATCH 8/8] checkout: move post_checkout_hook() to checkout.c Junio C Hamano
2026-08-28 22:57                     ` Junio C Hamano
2026-08-29  2:05                       ` Junio C Hamano
2026-08-29 13:24                 ` [PATCH] builtin: replace the_repository parameter in is_bare_repository() D. Ben Knoble
2026-08-27 21:35         ` [PATCH] do not pass "repo" to builtin commmand implementations Junio C Hamano
2026-08-28  9:05           ` Hardik Kumar
2026-08-28 20:59             ` Junio C Hamano
2026-08-28  4:01         ` [PATCH] builtin: replace the_repository parameter in is_bare_repository() Hardik Kumar
2026-08-27 19:56   ` Hardik Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.