]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: extract http_reauth_prepare() from retry paths
authorMatthew John Cheetham <mjcheetham@outlook.com>
Thu, 16 Apr 2026 09:20:57 +0000 (09:20 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Apr 2026 16:15:17 +0000 (09:15 -0700)
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>
http.c
http.h
remote-curl.c

diff --git a/http.c b/http.c
index 67c9c6fc60673d8f536979560b78a0aeabe71a0d..f3ba2964b943ef0e7cf7a486fccbff10a18d951e 100644 (file)
--- a/http.c
+++ b/http.c
@@ -665,6 +665,11 @@ static void init_curl_http_auth(CURL *result)
        }
 }
 
+void http_reauth_prepare(int all_capabilities)
+{
+       credential_fill(the_repository, &http_auth, all_capabilities);
+}
+
 /* *var must be free-able */
 static void var_override(char **var, char *value)
 {
@@ -2398,7 +2403,7 @@ static int http_request_recoverable(const char *url,
                                sleep(retry_delay);
                        }
                } else if (ret == HTTP_REAUTH) {
-                       credential_fill(the_repository, &http_auth, 1);
+                       http_reauth_prepare(1);
                }
 
                ret = http_request(url, result, target, options);
diff --git a/http.h b/http.h
index f9ee888c3ed67ef391c0f97e55135a1b10db2df0..729c51904d39ad789a016dbcbfdfa3a07fc4fcc8 100644 (file)
--- a/http.h
+++ b/http.h
@@ -76,6 +76,12 @@ extern int http_is_verbose;
 extern ssize_t http_post_buffer;
 extern struct credential http_auth;
 
+/**
+ * Prepare for an HTTP re-authentication retry. This fills credentials
+ * via credential_fill() so the next request can include them.
+ */
+void http_reauth_prepare(int all_capabilities);
+
 extern char curl_errorstr[CURL_ERROR_SIZE];
 
 enum http_follow_config {
index aba60d571282d39287cb8434de72af8c9a8a7a05..affdb880f7b3bfd1a4dc632f2d5717dc71ee48a5 100644 (file)
@@ -946,7 +946,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
                do {
                        err = probe_rpc(rpc, &results);
                        if (err == HTTP_REAUTH)
-                               credential_fill(the_repository, &http_auth, 0);
+                               http_reauth_prepare(0);
                } while (err == HTTP_REAUTH);
                if (err != HTTP_OK)
                        return -1;
@@ -1068,7 +1068,7 @@ retry:
        rpc->any_written = 0;
        err = run_slot(slot, NULL);
        if (err == HTTP_REAUTH && !large_request) {
-               credential_fill(the_repository, &http_auth, 0);
+               http_reauth_prepare(0);
                curl_slist_free_all(headers);
                goto retry;
        }