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

[PATCH 13/19] transport.c: remove implicit dependency on the_index

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Oct 19, 2018, 14:52 UTC
Message-ID
<20181019145237.16079-14-pclouds@gmail.com>
In-Reply-To
<20181019145237.16079-1-pclouds@gmail.com>

note, there's still another hidden dependency related to this: even though we pass a repo to transport_push() we still use is_bare_repository() which pretty much assumes the_repository (and some other global state).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/push.c | 3 ++-
 transport.c    | 7 ++++---
 transport.h    | 3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index d09a42062c..efb3e38a8d 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -355,7 +355,8 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
 
 	if (verbosity > 0)
 		fprintf(stderr, _("Pushing to %s\n"), transport->url);
-	err = transport_push(transport, rs, flags, &reject_reasons);
+	err = transport_push(the_repository, transport,
+			     rs, flags, &reject_reasons);
 	if (err != 0) {
 		fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
 		error(_("failed to push some refs to '%s'"), transport->url);
diff --git a/transport.c b/transport.c
index f4ffbd96cb..b86b2b12c6 100644
--- a/transport.c
+++ b/transport.c
@@ -1105,7 +1105,8 @@ static int run_pre_push_hook(struct transport *transport,
 	return ret;
 }
 
-int transport_push(struct transport *transport,
+int transport_push(struct repository *repo,
+		   struct transport *transport,
 		   struct refspec *rs, int flags,
 		   unsigned int *reject_reasons)
 {
@@ -1172,7 +1173,7 @@ int transport_push(struct transport *transport,
 					oid_array_append(&commits,
 							  &ref->new_oid);
 
-			if (!push_unpushed_submodules(&the_index,
+			if (!push_unpushed_submodules(repo->index,
 						      &commits,
 						      transport->remote,
 						      rs,
@@ -1197,7 +1198,7 @@ int transport_push(struct transport *transport,
 					oid_array_append(&commits,
 							  &ref->new_oid);
 
-			if (find_unpushed_submodules(&the_index,
+			if (find_unpushed_submodules(repo->index,
 						     &commits,
 						     transport->remote->name,
 						     &needs_pushing)) {
diff --git a/transport.h b/transport.h
index 9baeca2d7a..f2ee7c4f49 100644
--- a/transport.h
+++ b/transport.h
@@ -223,7 +223,8 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
 #define REJECT_FETCH_FIRST     0x08
 #define REJECT_NEEDS_FORCE     0x10
 
-int transport_push(struct transport *connection,
+int transport_push(struct repository *repo,
+		   struct transport *connection,
 		   struct refspec *rs, int flags,
 		   unsigned int * reject_reasons);
 
-- 
2.19.1.647.g708186aaf9
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 13 of 22 in “Kill the_index, final part”
  1. 00/19 Kill the_index, final partNguyễn Thái Ngọc Duy, Oct 19, 2018
  2. 01/19 wt-status.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  3. 02/19 wt-status.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy, Oct 19, 2018
  4. 03/19 list-objects-filter.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  5. 04/19 list-objects.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  6. 06/19 sequencer.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy, Oct 19, 2018
  7. 05/19 sequencer.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  8. 08/19 notes-merge.c: remove implicit dependency the_repositoryNguyễn Thái Ngọc Duy, Oct 19, 2018
  9. 07/19 notes-merge.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  10. 09/19 repository.c: replace hold_locked_index() with repo_hold_locked_index()Nguyễn Thái Ngọc Duy, Oct 19, 2018
  11. 10/19 checkout: avoid the_index when possibleNguyễn Thái Ngọc Duy, Oct 19, 2018
  12. 12/19 read-cache.c: replace update_index_if_able with repo_&Nguyễn Thái Ngọc Duy, Oct 19, 2018
  13. 13/19 transport.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  14. 11/19 read-cache.c: kill read_index()Nguyễn Thái Ngọc Duy, Oct 19, 2018
  15. 14/19 sha1-name.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  16. 16/19 merge-recursive.c: remove implicit dependency on the_repositoryNguyễn Thái Ngọc Duy, Oct 19, 2018
  17. 15/19 merge-recursive.c: remove implicit dependency on the_indexNguyễn Thái Ngọc Duy, Oct 19, 2018
  18. 17/19 read-cache.c: remove the_* from index_has_changes()Nguyễn Thái Ngọc Duy, Oct 19, 2018
  19. 19/19 Flip NO_THE_REPOSITORY_COMPATIBILITY_MACROSNguyễn Thái Ngọc Duy, Oct 19, 2018
  20. 18/19 cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchNguyễn Thái Ngọc Duy, Oct 19, 2018
  21. Stefan BellerOct 19, 2018
  22. Duy NguyenOct 29, 2018

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.