bug: request-pull broken when remote name contains a slash

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

bug: request-pull broken when remote name contains a slash

From: Uwe Kleine-König <hidden>
Date: 2016-06-15 22:50:25

Hello,

the remotes in my linux repo look as follows:

	[remote "ptx/ukl"]
		url = git://git.pengutronix.de/git/ukl/linux-2.6.git
		push = +refs/heads/*:refs/heads/*
		fetch = +refs/heads/*:refs/remotes/ptx/ukl/*

	[remote "ptx/otheruser"]
		url = git://git.pengutronix.de/git/otheruser/linux-2.6.git
		fetch = +refs/heads/*:refs/remotes/ptx/otheruser/*

	[remote "ptx/yetanotheruser"]
		url = git://git.pengutronix.de/git/yetanotheruser/linux-2.6.git
		fetch = +refs/heads/*:refs/remotes/ptx/yetanotheruser/*

unfortunately this makes sending request pulls uncomfortable:

	ukl@octopus:~/gsrc/linux-2.6$ git request-pull HEAD^ ptx/ukl
	The following changes since commit a08948812b30653eb2c536ae613b635a989feb6f:

	  Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging (2011-01-10 08:57:46 -0800)

	are available in the git repository at:

	  ptx/ukl mxs/for-2.6.38
	...

The reason for that is in git-parse-remote.sh:get_data_source() which
assumes that a remote with a slash is a filename and so get_remote_url
doesn't use $(git config --get "remote.$1.url") but ptx/ukl directly.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[PATCH] fix git-parse-remote.sh for remotes that contain slashes

From: Stefan Naewe <hidden>
Date: 2016-06-15 22:50:25

Signed-off-by: Stefan Naewe <redacted>
---
 git-parse-remote.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..7cf204e 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -7,8 +7,12 @@ GIT_DIR=$(git rev-parse -q --git-dir) || :;
 get_data_source () {
 	case "$1" in
 	*/*)
-		echo ''
-		;;
+		if test "$(git config --get "remote.$1.url")"
+		then
+			echo config
+		else
+			echo ''
+		fi ;;
 	.)
 		echo self
 		;;
-- 
1.7.3.5

[PATCH] get_remote_url(): use the same data source as ls-remote to get remote urls

From: Uwe Kleine-König <hidden>
Date: 2016-06-15 22:50:40

The formerly implemented algorithm behaved differently to
remote.c:remote_get() at least for remotes that contain a slash.  While the
former just assumes a/b is a path the latter checks the config for
remote."a/b" first which is more reasonable.

Signed-off-by: Uwe Kleine-König <redacted>
---
Hello,

with this patch git-request-pull.sh (== the only in-tree user of
git-parse-remote.sh:get_remote_url()) could directly use

	git ls-remote --get-url

.  I guess you wouldn't want to remove git-parse-remote.sh:get_remote_url()
though?!  Maybe add a deprecation warning to it?  The same applies to
git-parse-remote.sh:get_data_source() that isn't used anymore already with this
patch.

Best regards
Uwe

 builtin/ls-remote.c |   11 +++++++++++
 git-parse-remote.sh |   24 +-----------------------
 2 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 97eed40..1a1ff87 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -33,6 +33,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	int i;
 	const char *dest = NULL;
 	unsigned flags = 0;
+	int get_url = 0;
 	int quiet = 0;
 	const char *uploadpack = NULL;
 	const char **pattern = NULL;
@@ -69,6 +70,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 				quiet = 1;
 				continue;
 			}
+			if (!strcmp("--get-url", arg)) {
+				get_url = 1;
+				continue;
+			}
 			usage(ls_remote_usage);
 		}
 		dest = arg;
@@ -94,6 +99,12 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	}
 	if (!remote->url_nr)
 		die("remote %s has no configured URL", dest);
+
+	if (get_url) {
+		printf("%s\n", *remote->url);
+		return 0;
+	}
+
 	transport = transport_get(remote, NULL);
 	if (uploadpack != NULL)
 		transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 1cc2ba6..4fb778e 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -29,29 +29,7 @@ get_data_source () {
 }
 
 get_remote_url () {
-	data_source=$(get_data_source "$1")
-	case "$data_source" in
-	'')
-		echo "$1"
-		;;
-	self)
-		echo "$1"
-		;;
-	config)
-		git config --get "remote.$1.url"
-		;;
-	remotes)
-		sed -ne '/^URL: */{
-			s///p
-			q
-		}' "$GIT_DIR/remotes/$1"
-		;;
-	branches)
-		sed -e 's/#.*//' "$GIT_DIR/branches/$1"
-		;;
-	*)
-		die "internal error: get-remote-url $1" ;;
-	esac
+	git ls-remote --get-url "$1"
 }
 
 get_default_remote () {
-- 
1.7.2.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help