]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'gc/remote-with-fewer-static-global-variables'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Dec 2021 22:35:02 +0000 (14:35 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Dec 2021 22:35:02 +0000 (14:35 -0800)
Code clean-up to eventually allow information on remotes defined
for an arbitrary repository to be read.

* gc/remote-with-fewer-static-global-variables:
  remote: die if branch is not found in repository
  remote: remove the_repository->remote_state from static methods
  remote: use remote_state parameter internally
  remote: move static variables into per-repository struct
  t5516: add test case for pushing remote refspecs

1  2 
remote.c

diff --cc remote.c
index f958543d707d0da5282b7fb1bbb70a53bc834647,c97c626eaa83908408848733d2db32cbbe097931..a6d8ec6c1ac72f8b3b95978d11c87dd0b4918c01
+++ b/remote.c
@@@ -441,25 -498,26 +498,27 @@@ static void alias_all_urls(struct remot
        }
  }
  
- static void read_config(void)
+ static void read_config(struct repository *repo)
  {
-       static int loaded;
        int flag;
  
-       if (loaded)
+       if (repo->remote_state->initialized)
                return;
-       loaded = 1;
+       repo->remote_state->initialized = 1;
  
-       current_branch = NULL;
+       repo->remote_state->current_branch = NULL;
        if (startup_info->have_repository) {
-               const char *head_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flag);
++              int ignore_errno;
+               const char *head_ref = refs_resolve_ref_unsafe(
 -                      get_main_ref_store(repo), "HEAD", 0, NULL, &flag);
++                      get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno);
                if (head_ref && (flag & REF_ISSYMREF) &&
                    skip_prefix(head_ref, "refs/heads/", &head_ref)) {
-                       current_branch = make_branch(head_ref, strlen(head_ref));
+                       repo->remote_state->current_branch = make_branch(
+                               repo->remote_state, head_ref, strlen(head_ref));
                }
        }
-       git_config(handle_config, NULL);
-       alias_all_urls();
+       repo_config(repo, handle_config, repo->remote_state);
+       alias_all_urls(repo->remote_state);
  }
  
  static int valid_remote_nick(const char *name)