http: extract http_reauth_prepare() from retry paths
All three HTTP retry paths (http_request_recoverable, post_rpc, probe_rpc) call credential_fill() directly when handling HTTP_REAUTH. Extract this into a helper function so that a subsequent commit can add pre-fill logic (such as attempting empty-auth before prompting) in one place. No functional change. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthew John Cheetham committed
Apr 16, 2026 at 09:20 UTC
a8faa7a56033486c576b6386798dca4591e163eb
3 files changed
+14
-3
http.c
+6
-1
@@ -665,6 +665,11 @@ static void init_curl_http_auth(CURL *result)
665
}
666
}
667
668
+void http_reauth_prepare(int all_capabilities)
669
+{
670
+ credential_fill(the_repository, &http_auth, all_capabilities);
671
+}
672
+
673
/* *var must be free-able */
674
static void var_override(char **var, char *value)
675
{
@@ -2398,7 +2403,7 @@ static int http_request_recoverable(const char *url,
2403
sleep(retry_delay);
2404
}
2405
} else if (ret == HTTP_REAUTH) {
2401
- credential_fill(the_repository, &http_auth, 1);
2406
+ http_reauth_prepare(1);
2407
}
2408
2409
ret = http_request(url, result, target, options);
http.h
+6
@@ -76,6 +76,12 @@ extern int http_is_verbose;
76
extern ssize_t http_post_buffer;
77
extern struct credential http_auth;
78
79
+/**
80
+ * Prepare for an HTTP re-authentication retry. This fills credentials
81
+ * via credential_fill() so the next request can include them.
82
+ */
83
+void http_reauth_prepare(int all_capabilities);
84
+
85
extern char curl_errorstr[CURL_ERROR_SIZE];
86
87
enum http_follow_config {
remote-curl.c
+2
-2
@@ -946,7 +946,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
946
do {
947
err = probe_rpc(rpc, &results);
948
if (err == HTTP_REAUTH)
949
- credential_fill(the_repository, &http_auth, 0);
949
+ http_reauth_prepare(0);
950
} while (err == HTTP_REAUTH);
951
if (err != HTTP_OK)
952
return -1;
@@ -1068,7 +1068,7 @@ retry:
1068
rpc->any_written = 0;
1069
err = run_slot(slot, NULL);
1070
if (err == HTTP_REAUTH && !large_request) {
1071
- credential_fill(the_repository, &http_auth, 0);
1071
+ http_reauth_prepare(0);
1072
curl_slist_free_all(headers);
1073
goto retry;
1074
}