@@ -334,11 +334,10 @@ static void warn_about_deprecated_remote_type(const char *type,
334
334
type , remote -> name , remote -> name , remote -> name );
335
335
}
336
336
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 )
339
338
{
340
339
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 ,
342
341
"remotes/%s" , remote -> name ), "r" );
343
342
344
343
if (!f )
@@ -354,7 +353,7 @@ static void read_remotes_file(struct remote_state *remote_state,
354
353
strbuf_rtrim (& buf );
355
354
356
355
if (skip_prefix (buf .buf , "URL:" , & v ))
357
- add_url_alias (remote_state , remote ,
356
+ add_url_alias (repo -> remote_state , remote ,
358
357
skip_spaces (v ));
359
358
else if (skip_prefix (buf .buf , "Push:" , & v ))
360
359
refspec_append (& remote -> push , skip_spaces (v ));
@@ -367,12 +366,11 @@ static void read_remotes_file(struct remote_state *remote_state,
367
366
strbuf_release (& buf );
368
367
}
369
368
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 )
372
370
{
373
371
char * frag , * to_free = NULL ;
374
372
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 ,
376
374
"branches/%s" , remote -> name ), "r" );
377
375
378
376
if (!f )
@@ -399,9 +397,9 @@ static void read_branches_file(struct remote_state *remote_state,
399
397
if (frag )
400
398
* (frag ++ ) = '\0' ;
401
399
else
402
- frag = to_free = repo_default_branch_name (the_repository , 0 );
400
+ frag = to_free = repo_default_branch_name (repo , 0 );
403
401
404
- add_url_alias (remote_state , remote , buf .buf );
402
+ add_url_alias (repo -> remote_state , remote , buf .buf );
405
403
refspec_appendf (& remote -> fetch , "refs/heads/%s:refs/heads/%s" ,
406
404
frag , remote -> name );
407
405
@@ -698,7 +696,7 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit)
698
696
branch , explicit );
699
697
}
700
698
701
- static struct remote * remotes_remote_get (struct remote_state * remote_state ,
699
+ static struct remote * remotes_remote_get (struct repository * repo ,
702
700
const char * name );
703
701
704
702
char * 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)
717
715
the_repository -> remote_state , branch ,
718
716
NULL );
719
717
struct remote * remote = remotes_remote_get (
720
- the_repository -> remote_state , remote_name );
718
+ the_repository , remote_name );
721
719
722
720
if (remote && remote -> push .nr &&
723
721
(dst = apply_refspecs (& remote -> push ,
@@ -774,10 +772,11 @@ static void validate_remote_url(struct remote *remote)
774
772
}
775
773
776
774
static 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 ,
778
776
const char * (* get_default )(struct remote_state * ,
779
777
struct branch * , int * ))
780
778
{
779
+ struct remote_state * remote_state = repo -> remote_state ;
781
780
struct remote * ret ;
782
781
int name_given = 0 ;
783
782
@@ -791,9 +790,9 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
791
790
#ifndef WITH_BREAKING_CHANGES
792
791
if (valid_remote_nick (name ) && have_git_dir ()) {
793
792
if (!valid_remote (ret ))
794
- read_remotes_file (remote_state , ret );
793
+ read_remotes_file (repo , ret );
795
794
if (!valid_remote (ret ))
796
- read_branches_file (remote_state , ret );
795
+ read_branches_file (repo , ret );
797
796
}
798
797
#endif /* WITH_BREAKING_CHANGES */
799
798
if (name_given && !valid_remote (ret ))
@@ -807,35 +806,33 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
807
806
}
808
807
809
808
static 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 )
811
810
{
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 );
814
812
}
815
813
816
814
struct remote * remote_get (const char * name )
817
815
{
818
816
read_config (the_repository , 0 );
819
- return remotes_remote_get (the_repository -> remote_state , name );
817
+ return remotes_remote_get (the_repository , name );
820
818
}
821
819
822
820
struct remote * remote_get_early (const char * name )
823
821
{
824
822
read_config (the_repository , 1 );
825
- return remotes_remote_get (the_repository -> remote_state , name );
823
+ return remotes_remote_get (the_repository , name );
826
824
}
827
825
828
826
static 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 )
830
828
{
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 );
833
830
}
834
831
835
832
struct remote * pushremote_get (const char * name )
836
833
{
837
834
read_config (the_repository , 0 );
838
- return remotes_pushremote_get (the_repository -> remote_state , name );
835
+ return remotes_pushremote_get (the_repository , name );
839
836
}
840
837
841
838
int 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,
1739
1736
}
1740
1737
}
1741
1738
1742
- static void set_merge (struct remote_state * remote_state , struct branch * ret )
1739
+ static void set_merge (struct repository * repo , struct branch * ret )
1743
1740
{
1744
1741
struct remote * remote ;
1745
1742
char * ref ;
@@ -1760,13 +1757,13 @@ static void set_merge(struct remote_state *remote_state, struct branch *ret)
1760
1757
}
1761
1758
ret -> set_merge = 1 ;
1762
1759
1763
- remote = remotes_remote_get (remote_state , ret -> remote_name );
1760
+ remote = remotes_remote_get (repo , ret -> remote_name );
1764
1761
1765
1762
for (i = 0 ; i < ret -> merge_nr ; i ++ ) {
1766
1763
if (!remote_find_tracking (remote , ret -> merge [i ]) ||
1767
1764
strcmp (ret -> remote_name , "." ))
1768
1765
continue ;
1769
- if (repo_dwim_ref (the_repository , ret -> merge [i ]-> src ,
1766
+ if (repo_dwim_ref (repo , ret -> merge [i ]-> src ,
1770
1767
strlen (ret -> merge [i ]-> src ), & oid , & ref ,
1771
1768
0 ) == 1 )
1772
1769
ret -> merge [i ]-> dst = ref ;
@@ -1785,7 +1782,7 @@ struct branch *branch_get(const char *name)
1785
1782
else
1786
1783
ret = make_branch (the_repository -> remote_state , name ,
1787
1784
strlen (name ));
1788
- set_merge (the_repository -> remote_state , ret );
1785
+ set_merge (the_repository , ret );
1789
1786
return ret ;
1790
1787
}
1791
1788
@@ -1856,13 +1853,14 @@ static const char *tracking_for_push_dest(struct remote *remote,
1856
1853
return ret ;
1857
1854
}
1858
1855
1859
- static const char * branch_get_push_1 (struct remote_state * remote_state ,
1856
+ static const char * branch_get_push_1 (struct repository * repo ,
1860
1857
struct branch * branch , struct strbuf * err )
1861
1858
{
1859
+ struct remote_state * remote_state = repo -> remote_state ;
1862
1860
struct remote * remote ;
1863
1861
1864
1862
remote = remotes_remote_get (
1865
- remote_state ,
1863
+ repo ,
1866
1864
remotes_pushremote_for_branch (remote_state , branch , NULL ));
1867
1865
if (!remote )
1868
1866
return error_buf (err ,
@@ -1929,7 +1927,7 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
1929
1927
1930
1928
if (!branch -> push_tracking_ref )
1931
1929
branch -> push_tracking_ref = branch_get_push_1 (
1932
- the_repository -> remote_state , branch , err );
1930
+ the_repository , branch , err );
1933
1931
return branch -> push_tracking_ref ;
1934
1932
}
1935
1933
0 commit comments