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

[PATCH] builtin: replace the_repository parameter in is_bare_repository()

From
Hardik Kumar <hardikxk@gmail.com>
Date
Aug 27, 2026, 18:29 UTC
Message-ID
<20260827-env-is_bare_repo-v1-1-aa99600dc213@gmail.com>

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
Next: Junio C Hamano
Message 1 of 47 in “builtin: replace the_repository parameter in is_bare_repository()”
  1. builtin: replace the_repository parameter in is_bare_repository()Hardik Kumar, Aug 27, 2026
  2. Junio C HamanoAug 27, 2026
  3. Junio C HamanoAug 27, 2026
  4. Hardik KumarAug 27, 2026
  5. Junio C HamanoAug 27, 2026
  6. Ben KnobleAug 27, 2026
  7. Junio C HamanoAug 27, 2026
  8. D. Ben KnobleAug 28, 2026
  9. Junio C HamanoAug 28, 2026
  10. 0/8 More sensible checkout/switch/restore code refactoringJunio C Hamano, Aug 28, 2026
  11. 1/8 checkout: pass cb_option explicitly to branch name parsersJunio C Hamano, Aug 28, 2026
  12. 2/8 checkout: validate new branch name in checkout_branch()Junio C Hamano, Aug 28, 2026
  13. 3/8 checkout: validate stage and merge option compatibility in checkout_paths()Junio C Hamano, Aug 28, 2026
  14. 4/8 checkout: extract option validation and pathspec helpersJunio C Hamano, Aug 28, 2026
  15. 5/8 checkout: extract branch setup and tracking helpersJunio C Hamano, Aug 28, 2026
  16. 6/8 checkout: restructure switch, restore, and checkout entrypointsJunio C Hamano, Aug 28, 2026
  17. 7/8 checkout: wrap overly long linesJunio C Hamano, Aug 28, 2026
  18. Junio C HamanoAug 28, 2026
  19. Junio C HamanoAug 29, 2026
  20. 8/8 checkout: move post_checkout_hook() to checkout.cJunio C Hamano, Aug 28, 2026
  21. Junio C HamanoAug 28, 2026
  22. Junio C HamanoAug 29, 2026
  23. 0/8 More sensible checkout/switch/restore code refactoringJunio C Hamano, Aug 30, 2026
  24. 1/8 checkout: pass cb_option explicitly to branch name parsersJunio C Hamano, Aug 30, 2026
  25. Karthik NayakSep 1, 2026
  26. 2/8 checkout: validate new branch name in checkout_branch()Junio C Hamano, Aug 30, 2026
  27. Karthik NayakSep 1, 2026
  28. 3/8 checkout: validate stage and merge option compatibility in checkout_paths()Junio C Hamano, Aug 30, 2026
  29. Karthik NayakSep 1, 2026
  30. Junio C HamanoSep 1, 2026
  31. Karthik NayakSep 2, 2026
  32. Junio C HamanoSep 2, 2026
  33. Karthik NayakSep 3, 2026
  34. 4/8 checkout: extract option validation and pathspec helpersJunio C Hamano, Aug 30, 2026
  35. 5/8 checkout: extract branch setup and tracking helpersJunio C Hamano, Aug 30, 2026
  36. 6/8 checkout: restructure switch, restore, and checkout entrypointsJunio C Hamano, Aug 30, 2026
  37. Karthik NayakSep 1, 2026
  38. Junio C HamanoSep 1, 2026
  39. Karthik NayakSep 2, 2026
  40. 7/8 checkout: wrap overly long linesJunio C Hamano, Aug 30, 2026
  41. 8/8 checkout: move post_checkout_hook() to checkout.cJunio C Hamano, Aug 30, 2026
  42. D. Ben KnobleAug 29, 2026
  43. do not pass "repo" to builtin commmand implementationsJunio C Hamano, Aug 27, 2026
  44. Hardik KumarAug 28, 2026
  45. Junio C HamanoAug 28, 2026
  46. Hardik KumarAug 28, 2026
  47. Hardik KumarAug 27, 2026

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.