~herrhotzenplotz/gcli-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH gcli] gitconfig: add support for remotes with ssh-urls containing port numbers

Details
Message ID
<20241003103247.7239-1-nsonack@herrhotzenplotz.de>
DKIM signature
pass
Download raw message
Patch: +9 -0
I discovered that when we clone out a repository with ssh but the
URL has a port number in it gcli errors out by default when trying
to fetch anything.
This is because it puts the port number into the owner and the
resulting API endpoint is thus always incorrect.

Fix this by checking if anything after the first colon is a digit
and skip until we find a slash.

Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de>
---
 src/cmd/gitconfig.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/cmd/gitconfig.c b/src/cmd/gitconfig.c
index a24eb98..a03f373 100644
--- a/src/cmd/gitconfig.c
+++ b/src/cmd/gitconfig.c
@@ -34,6 +34,7 @@
#include <gcli/gcli.h>
#include <sn/sn.h>

#include <ctype.h>
#include <dirent.h>
#include <signal.h>
#include <stdio.h>
@@ -332,6 +333,14 @@ ssh_extractor(struct gcli_gitremote *const remote, char const *prefix)
	pair.data   += 1;
	pair.length -= 1;

	/* sometimes we see port numbers in the SSH url */
	if (isdigit(*pair.data)) {
		sn_sv_chop_until(&pair, '/');

		pair.data   += 1;
		pair.length -= 1;
	}

	remote->owner = sn_sv_chop_until(&pair, '/');

	pair.data   += 1;
-- 
2.45.2
Reply to thread Export thread (mbox)