summaryrefslogtreecommitdiffstats
path: root/remote.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-06-14 12:29:09 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-14 18:34:38 +0200
commitb68118d2e85eef7aa993ef8e944e53b5be665160 (patch)
tree498802a667ce3bcd3d2febf0b86c889bada10e25 /remote.h
parentremote: use strvecs to store remote url/pushurl (diff)
downloadgit-b68118d2e85eef7aa993ef8e944e53b5be665160.tar.xz
git-b68118d2e85eef7aa993ef8e944e53b5be665160.zip
remote: simplify url/pushurl selection
When we want to know the push urls for a remote, there is some simple logic: - if the user configured any remote.*.pushurl keys, then those make the complete set of push urls - otherwise we push to all urls in remote.*.url Many spots implement this with a level of indirection, assigning to a local url/url_nr pair. But since both arrays are now strvecs, we can just use a pointer to select the appropriate strvec, shortening the code a bit. Even though this is now a one-liner, since it is application logic that is present in so many places, it's worth abstracting a helper function. In fact, we already have such a function, but it's local to builtin/push.c. So we'll just make it available everywhere via remote.h. There are two spots to pay special attention to here: 1. in builtin/remote.c's get_url(), we are selecting first based on push_mode and then falling back to "url" when we're in push_mode but no pushurl is defined. The updated code makes that much more clear, compared to the original which had an "else" fall-through. 2. likewise in that file's set_url(), we _only_ respect push_mode, sine the point is that we are adding to pushurl in that case (whether it is empty or not). And thus it does not use our helper function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.h')
-rw-r--r--remote.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/remote.h b/remote.h
index 84dc91cca0..034f9d6660 100644
--- a/remote.h
+++ b/remote.h
@@ -123,6 +123,7 @@ typedef int each_remote_fn(struct remote *remote, void *priv);
int for_each_remote(each_remote_fn fn, void *priv);
int remote_has_url(struct remote *remote, const char *url);
+struct strvec *push_url_of_remote(struct remote *remote);
struct ref_push_report {
const char *ref_name;