"GOT", but the "O" is a cute, smiling sun Index | Thread

From:
Omar Polo <op@omarpolo.com>
Subject:
got clone/send/fetch: print full URL
To:
gameoftrees@openbsd.org
Date:
Fri, 18 Nov 2022 11:12:28 +0100

Download raw body.

When dealing with multiple repositories on the same remote host
(i.e. web forges) I often confuse or forget to specify the correct
remote name.

Currently, got shows:

	% got send fork
	Connecting to "fork" git@github.com

	% got fetch
	Connecting to "origin" git@github.com

Diff below shows instead:

	% got send fork
	Connecting to ssh://git@github.com/omar-polo/picom

	% got fetch
	Connecting to ssh://git@github.com/yshui/picom


With web forges it's not useful to read only the user@host part
because the path is more important, and while here why don't waste
some chars for the protocol too to make a full URL?

I've removed the remote name in part to make some room and also
because it's a bit redundant (it's either "origin" or the one
specified in the command line.)

what do y'all think?


-----------------------------------------------
commit c9a8fe6ee0c8fdad87caf8947f584d8903931b14 (fullurl)
from: Omar Polo <op@omarpolo.com>
date: Fri Nov 18 09:55:42 2022 UTC
 
 show full URL in got clone/fetch/send
 
diff 8c6fc1468a57de4851e137b55bda5cd838e2f759 c9a8fe6ee0c8fdad87caf8947f584d8903931b14
commit - 8c6fc1468a57de4851e137b55bda5cd838e2f759
commit + c9a8fe6ee0c8fdad87caf8947f584d8903931b14
blob - 63af2b9f40b9e8782cba105f307f72d0a7180caa
blob + 2598d733bf092ae271e0eac5b23099c7d6d67eca
--- got/got.c
+++ got/got.c
@@ -1694,8 +1694,7 @@ cmd_clone(int argc, char *argv[])
 		goto done;
 
 	if (verbosity >= 0)
-		printf("Connecting to %s%s%s\n", host,
-		    port ? ":" : "", port ? port : "");
+		printf("Connecting to %s\n", git_url);
 
 	error = got_fetch_connect(&fetchpid, &fetchfd, proto, host, port,
 	    server_path, verbosity);
@@ -2538,9 +2537,11 @@ cmd_fetch(int argc, char *argv[])
 	if (error)
 		goto done;
 
-	if (verbosity >= 0)
-		printf("Connecting to \"%s\" %s%s%s\n", remote->name, host,
-		    port ? ":" : "", port ? port : "");
+	if (verbosity >= 0) {
+		printf("Connecting to %s://%s%s%s%s%s\n",
+		    proto, host, port ? ":" : "", port ? port : "",
+		    *server_path == '/' ? "" : "/", server_path);
+	}
 
 	error = got_fetch_connect(&fetchpid, &fetchfd, proto, host, port,
 	    server_path, verbosity);
@@ -9215,9 +9216,11 @@ cmd_send(int argc, char *argv[])
 		nbranches++;
 	}
 
-	if (verbosity >= 0)
-		printf("Connecting to \"%s\" %s%s%s\n", remote->name, host,
-		    port ? ":" : "", port ? port : "");
+	if (verbosity >= 0) {
+		printf("Connecting to %s://%s%s%s%s%s\n",
+		    proto, host, port ? ":" : "", port ? port : "",
+		    *server_path == '/' ? "" : "/", server_path);
+	}
 
 	error = got_send_connect(&sendpid, &sendfd, proto, host, port,
 	    server_path, verbosity);
blob - 6881cc1cec543e7bfd4986adaba1e99620dfeabd
blob + edb0516b38e63ce6695a517988a05d6c9a5266e3
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
@@ -132,7 +132,7 @@ test_clone_list() {
 
 test_clone_list() {
 	local testroot=`test_init clone_list`
-	local testurl=ssh://127.0.0.1/$testroot
+	local testurl=ssh://127.0.0.1$testroot
 	local commit_id=`git_show_head $testroot/repo`
 
 	got branch -r $testroot/repo -c $commit_id foo
@@ -147,7 +147,7 @@ test_clone_list() {
 		return 1
 	fi
 
-	echo "Connecting to 127.0.0.1" > $testroot/stdout.expected
+	echo "Connecting to $testurl/repo" > $testroot/stdout.expected
 	got ref -l -r $testroot/repo >> $testroot/stdout.expected
 
 	cmp -s $testroot/stdout $testroot/stdout.expected
blob - 2bfbfe22cdf4a0255e78921e2da2bfcc76ffb03c
blob + 7fcbcf74b2ad441e4fea7b1e962369ced3788969
--- regress/cmdline/send.sh
+++ regress/cmdline/send.sh
@@ -129,7 +129,8 @@ EOF
 		return 1
 	fi
 
-	echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
+	echo "Connecting to ssh://127.0.0.1$testroot/repo-clone" \
+		> $testroot/stdout.expected
 	echo "Already up-to-date" >> $testroot/stdout.expected
 	cmp -s $testroot/stdout $testroot/stdout.expected
 	ret=$?
@@ -398,7 +399,8 @@ EOF
 		return 1
 	fi
 
-	echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
+	echo "Connecting to ssh://127.0.0.1$testroot/repo-clone" \
+		> $testroot/stdout.expected
 	echo "Server has deleted refs/heads/branch2" \
 		>> $testroot/stdout.expected
 
@@ -1291,7 +1293,8 @@ EOF
 		return 1
 	fi
 
-	echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
+	echo "Connecting to ssh://127.0.0.1$testroot/repo2" \
+		> $testroot/stdout.expected
 	echo "Already up-to-date" >> $testroot/stdout.expected
 	cmp -s $testroot/stdout $testroot/stdout.expected
 	ret=$?