@@ -334,11 +334,10 @@ static void warn_about_deprecated_remote_type(const char *type,
334334 type , remote -> name , remote -> name , remote -> name );
335335}
336336
337- static void read_remotes_file (struct remote_state * remote_state ,
338- struct remote * remote )
337+ static void read_remotes_file (struct repository * repo , struct remote * remote )
339338{
340339 struct strbuf buf = STRBUF_INIT ;
341- FILE * f = fopen_or_warn (repo_git_path_append (the_repository , & buf ,
340+ FILE * f = fopen_or_warn (repo_git_path_append (repo , & buf ,
342341 "remotes/%s" , remote -> name ), "r" );
343342
344343 if (!f )
@@ -354,7 +353,7 @@ static void read_remotes_file(struct remote_state *remote_state,
354353 strbuf_rtrim (& buf );
355354
356355 if (skip_prefix (buf .buf , "URL:" , & v ))
357- add_url_alias (remote_state , remote ,
356+ add_url_alias (repo -> remote_state , remote ,
358357 skip_spaces (v ));
359358 else if (skip_prefix (buf .buf , "Push:" , & v ))
360359 refspec_append (& remote -> push , skip_spaces (v ));
@@ -367,12 +366,11 @@ static void read_remotes_file(struct remote_state *remote_state,
367366 strbuf_release (& buf );
368367}
369368
370- static void read_branches_file (struct remote_state * remote_state ,
371- struct remote * remote )
369+ static void read_branches_file (struct repository * repo , struct remote * remote )
372370{
373371 char * frag , * to_free = NULL ;
374372 struct strbuf buf = STRBUF_INIT ;
375- FILE * f = fopen_or_warn (repo_git_path_append (the_repository , & buf ,
373+ FILE * f = fopen_or_warn (repo_git_path_append (repo , & buf ,
376374 "branches/%s" , remote -> name ), "r" );
377375
378376 if (!f )
@@ -399,9 +397,9 @@ static void read_branches_file(struct remote_state *remote_state,
399397 if (frag )
400398 * (frag ++ ) = '\0' ;
401399 else
402- frag = to_free = repo_default_branch_name (the_repository , 0 );
400+ frag = to_free = repo_default_branch_name (repo , 0 );
403401
404- add_url_alias (remote_state , remote , buf .buf );
402+ add_url_alias (repo -> remote_state , remote , buf .buf );
405403 refspec_appendf (& remote -> fetch , "refs/heads/%s:refs/heads/%s" ,
406404 frag , remote -> name );
407405
@@ -698,7 +696,7 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit)
698696 branch , explicit );
699697}
700698
701- static struct remote * remotes_remote_get (struct remote_state * remote_state ,
699+ static struct remote * remotes_remote_get (struct repository * repo ,
702700 const char * name );
703701
704702char * remote_ref_for_branch (struct branch * branch , int for_push )
@@ -717,7 +715,7 @@ char *remote_ref_for_branch(struct branch *branch, int for_push)
717715 the_repository -> remote_state , branch ,
718716 NULL );
719717 struct remote * remote = remotes_remote_get (
720- the_repository -> remote_state , remote_name );
718+ the_repository , remote_name );
721719
722720 if (remote && remote -> push .nr &&
723721 (dst = apply_refspecs (& remote -> push ,
@@ -774,10 +772,11 @@ static void validate_remote_url(struct remote *remote)
774772}
775773
776774static struct remote *
777- remotes_remote_get_1 (struct remote_state * remote_state , const char * name ,
775+ remotes_remote_get_1 (struct repository * repo , const char * name ,
778776 const char * (* get_default )(struct remote_state * ,
779777 struct branch * , int * ))
780778{
779+ struct remote_state * remote_state = repo -> remote_state ;
781780 struct remote * ret ;
782781 int name_given = 0 ;
783782
@@ -791,9 +790,9 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
791790#ifndef WITH_BREAKING_CHANGES
792791 if (valid_remote_nick (name ) && have_git_dir ()) {
793792 if (!valid_remote (ret ))
794- read_remotes_file (remote_state , ret );
793+ read_remotes_file (repo , ret );
795794 if (!valid_remote (ret ))
796- read_branches_file (remote_state , ret );
795+ read_branches_file (repo , ret );
797796 }
798797#endif /* WITH_BREAKING_CHANGES */
799798 if (name_given && !valid_remote (ret ))
@@ -807,35 +806,33 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
807806}
808807
809808static inline struct remote *
810- remotes_remote_get (struct remote_state * remote_state , const char * name )
809+ remotes_remote_get (struct repository * repo , const char * name )
811810{
812- return remotes_remote_get_1 (remote_state , name ,
813- remotes_remote_for_branch );
811+ return remotes_remote_get_1 (repo , name , remotes_remote_for_branch );
814812}
815813
816814struct remote * remote_get (const char * name )
817815{
818816 read_config (the_repository , 0 );
819- return remotes_remote_get (the_repository -> remote_state , name );
817+ return remotes_remote_get (the_repository , name );
820818}
821819
822820struct remote * remote_get_early (const char * name )
823821{
824822 read_config (the_repository , 1 );
825- return remotes_remote_get (the_repository -> remote_state , name );
823+ return remotes_remote_get (the_repository , name );
826824}
827825
828826static inline struct remote *
829- remotes_pushremote_get (struct remote_state * remote_state , const char * name )
827+ remotes_pushremote_get (struct repository * repo , const char * name )
830828{
831- return remotes_remote_get_1 (remote_state , name ,
832- remotes_pushremote_for_branch );
829+ return remotes_remote_get_1 (repo , name , remotes_pushremote_for_branch );
833830}
834831
835832struct remote * pushremote_get (const char * name )
836833{
837834 read_config (the_repository , 0 );
838- return remotes_pushremote_get (the_repository -> remote_state , name );
835+ return remotes_pushremote_get (the_repository , name );
839836}
840837
841838int remote_is_configured (struct remote * remote , int in_repo )
@@ -1739,7 +1736,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
17391736 }
17401737}
17411738
1742- static void set_merge (struct remote_state * remote_state , struct branch * ret )
1739+ static void set_merge (struct repository * repo , struct branch * ret )
17431740{
17441741 struct remote * remote ;
17451742 char * ref ;
@@ -1760,13 +1757,13 @@ static void set_merge(struct remote_state *remote_state, struct branch *ret)
17601757 }
17611758 ret -> set_merge = 1 ;
17621759
1763- remote = remotes_remote_get (remote_state , ret -> remote_name );
1760+ remote = remotes_remote_get (repo , ret -> remote_name );
17641761
17651762 for (i = 0 ; i < ret -> merge_nr ; i ++ ) {
17661763 if (!remote_find_tracking (remote , ret -> merge [i ]) ||
17671764 strcmp (ret -> remote_name , "." ))
17681765 continue ;
1769- if (repo_dwim_ref (the_repository , ret -> merge [i ]-> src ,
1766+ if (repo_dwim_ref (repo , ret -> merge [i ]-> src ,
17701767 strlen (ret -> merge [i ]-> src ), & oid , & ref ,
17711768 0 ) == 1 )
17721769 ret -> merge [i ]-> dst = ref ;
@@ -1785,7 +1782,7 @@ struct branch *branch_get(const char *name)
17851782 else
17861783 ret = make_branch (the_repository -> remote_state , name ,
17871784 strlen (name ));
1788- set_merge (the_repository -> remote_state , ret );
1785+ set_merge (the_repository , ret );
17891786 return ret ;
17901787}
17911788
@@ -1856,13 +1853,14 @@ static const char *tracking_for_push_dest(struct remote *remote,
18561853 return ret ;
18571854}
18581855
1859- static const char * branch_get_push_1 (struct remote_state * remote_state ,
1856+ static const char * branch_get_push_1 (struct repository * repo ,
18601857 struct branch * branch , struct strbuf * err )
18611858{
1859+ struct remote_state * remote_state = repo -> remote_state ;
18621860 struct remote * remote ;
18631861
18641862 remote = remotes_remote_get (
1865- remote_state ,
1863+ repo ,
18661864 remotes_pushremote_for_branch (remote_state , branch , NULL ));
18671865 if (!remote )
18681866 return error_buf (err ,
@@ -1929,7 +1927,7 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
19291927
19301928 if (!branch -> push_tracking_ref )
19311929 branch -> push_tracking_ref = branch_get_push_1 (
1932- the_repository -> remote_state , branch , err );
1930+ the_repository , branch , err );
19331931 return branch -> push_tracking_ref ;
19341932}
19351933
0 commit comments