11
11
#include "credential.h"
12
12
13
13
static struct remote * remote ;
14
- static const char * url ; /* always ends with a trailing slash */
14
+ /* always ends with a trailing slash */
15
+ static struct strbuf url = STRBUF_INIT ;
15
16
16
17
struct options {
17
18
int verbosity ;
@@ -112,7 +113,8 @@ static struct ref *parse_info_refs(struct discovery *heads)
112
113
mid = & data [i ];
113
114
if (data [i ] == '\n' ) {
114
115
if (mid - start != 40 )
115
- die ("%sinfo/refs not valid: is this a git repository?" , url );
116
+ die ("%sinfo/refs not valid: is this a git repository?" ,
117
+ url .buf );
116
118
data [i ] = 0 ;
117
119
ref_name = mid + 1 ;
118
120
ref = xmalloc (sizeof (struct ref ) +
@@ -131,7 +133,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
131
133
}
132
134
133
135
ref = alloc_ref ("HEAD" );
134
- if (!http_fetch_ref (url , ref ) &&
136
+ if (!http_fetch_ref (url . buf , ref ) &&
135
137
!resolve_remote_symref (ref , refs )) {
136
138
ref -> next = refs ;
137
139
refs = ref ;
@@ -194,11 +196,11 @@ static struct discovery* discover_refs(const char *service, int for_push)
194
196
return last ;
195
197
free_discovery (last );
196
198
197
- strbuf_addf (& refs_url , "%sinfo/refs" , url );
198
- if ((!prefixcmp (url , "http://" ) || !prefixcmp (url , "https://" )) &&
199
+ strbuf_addf (& refs_url , "%sinfo/refs" , url . buf );
200
+ if ((!prefixcmp (url . buf , "http://" ) || !prefixcmp (url . buf , "https://" )) &&
199
201
git_env_bool ("GIT_SMART_HTTP" , 1 )) {
200
202
maybe_smart = 1 ;
201
- if (!strchr (url , '?' ))
203
+ if (!strchr (url . buf , '?' ))
202
204
strbuf_addch (& refs_url , '?' );
203
205
else
204
206
strbuf_addch (& refs_url , '&' );
@@ -216,13 +218,13 @@ static struct discovery* discover_refs(const char *service, int for_push)
216
218
break ;
217
219
case HTTP_MISSING_TARGET :
218
220
show_http_message (& type , & buffer );
219
- die ("repository '%s' not found" , url );
221
+ die ("repository '%s' not found" , url . buf );
220
222
case HTTP_NOAUTH :
221
223
show_http_message (& type , & buffer );
222
- die ("Authentication failed for '%s'" , url );
224
+ die ("Authentication failed for '%s'" , url . buf );
223
225
default :
224
226
show_http_message (& type , & buffer );
225
- die ("unable to access '%s': %s" , url , curl_errorstr );
227
+ die ("unable to access '%s': %s" , url . buf , curl_errorstr );
226
228
}
227
229
228
230
last = xcalloc (1 , sizeof (* last_discovery ));
@@ -588,7 +590,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
588
590
rpc -> out = client .out ;
589
591
strbuf_init (& rpc -> result , 0 );
590
592
591
- strbuf_addf (& buf , "%s%s" , url , svc );
593
+ strbuf_addf (& buf , "%s%s" , url . buf , svc );
592
594
rpc -> service_url = strbuf_detach (& buf , NULL );
593
595
594
596
strbuf_addf (& buf , "Content-Type: application/x-%s-request" , svc );
@@ -640,7 +642,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
640
642
for (i = 0 ; i < nr_heads ; i ++ )
641
643
targets [i ] = xstrdup (sha1_to_hex (to_fetch [i ]-> old_sha1 ));
642
644
643
- walker = get_http_walker (url );
645
+ walker = get_http_walker (url . buf );
644
646
walker -> get_all = 1 ;
645
647
walker -> get_tree = 1 ;
646
648
walker -> get_history = 1 ;
@@ -685,7 +687,7 @@ static int fetch_git(struct discovery *heads,
685
687
depth_arg = strbuf_detach (& buf , NULL );
686
688
argv [argc ++ ] = depth_arg ;
687
689
}
688
- argv [argc ++ ] = url ;
690
+ argv [argc ++ ] = url . buf ;
689
691
argv [argc ++ ] = NULL ;
690
692
691
693
for (i = 0 ; i < nr_heads ; i ++ ) {
@@ -783,7 +785,7 @@ static int push_dav(int nr_spec, char **specs)
783
785
argv [argc ++ ] = "--dry-run" ;
784
786
if (options .verbosity > 1 )
785
787
argv [argc ++ ] = "--verbose" ;
786
- argv [argc ++ ] = url ;
788
+ argv [argc ++ ] = url . buf ;
787
789
for (i = 0 ; i < nr_spec ; i ++ )
788
790
argv [argc ++ ] = specs [i ];
789
791
argv [argc ++ ] = NULL ;
@@ -813,7 +815,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
813
815
else if (options .verbosity > 1 )
814
816
argv_array_push (& args , "--verbose" );
815
817
argv_array_push (& args , options .progress ? "--progress" : "--no-progress" );
816
- argv_array_push (& args , url );
818
+ argv_array_push (& args , url . buf );
817
819
for (i = 0 ; i < nr_spec ; i ++ )
818
820
argv_array_push (& args , specs [i ]);
819
821
@@ -894,14 +896,12 @@ int main(int argc, const char **argv)
894
896
remote = remote_get (argv [1 ]);
895
897
896
898
if (argc > 2 ) {
897
- end_url_with_slash (& buf , argv [2 ]);
899
+ end_url_with_slash (& url , argv [2 ]);
898
900
} else {
899
- end_url_with_slash (& buf , remote -> url [0 ]);
901
+ end_url_with_slash (& url , remote -> url [0 ]);
900
902
}
901
903
902
- url = strbuf_detach (& buf , NULL );
903
-
904
- http_init (remote , url , 0 );
904
+ http_init (remote , url .buf , 0 );
905
905
906
906
do {
907
907
if (strbuf_getline (& buf , stdin , '\n' ) == EOF ) {
0 commit comments