~herrhotzenplotz/gcli-devel

gcli: gitconfig: add support for remotes with ssh-urls containing port numbers v1 APPLIED

Nico Sonack: 1
 gitconfig: add support for remotes with ssh-urls containing port numbers

 1 files changed, 9 insertions(+), 0 deletions(-)
build pending: alpine.yml
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~herrhotzenplotz/gcli-devel/patches/55288/mbox | git am -3
Learn more about email & git

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

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