[maintainer-tools PATCH] dim: fix remote repository lookup function

Andrzej Hajda a.hajda at samsung.com
Wed Sep 27 09:58:17 UTC 2017


On 25.08.2017 13:31, Andrzej Hajda wrote:
> dim finds remote name by matching repository urls, but different users
> requires different protocols/paths for remotes (ssh/git/https). Current
> code incorrectly translates provided url to alternatives, the patch
> fixes it.
>
> Signed-off-by: Andrzej Hajda <a.hajda at samsung.com>

Gently ping.

Andrzej

> ---
>  dim | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/dim b/dim
> index 11aa675..d6d9269 100755
> --- a/dim
> +++ b/dim
> @@ -223,15 +223,15 @@ fi
>  #	git branch name - dim assumes that the remote and local name match
>  # url:
>  #	url to a repo, using ssh:// protocol
> -# git_url:
> -#	url to a repo, but using anonymous git:// protocol
> +# urls:
> +#	alternative urls to a repo, derived from url
>  #
>  # The below functions map between these.
>  #
>  
>  function url_to_remote # url
>  {
> -	local url remote
> +	local url urls remote
>  
>  	url="$1"
>  
> @@ -240,19 +240,17 @@ function url_to_remote # url
>  		return 1
>  	fi
>  
> -	remote=$(git remote -v | grep -m 1 "$url" | cut -f 1)
> +	urls=$(echo $url | sed -r \
> +		-e 's!ssh://(git.freedesktop.org)/git/(.*)!\0|git://anon\1/\2|https://anon\1/git/\2.git!' \
> +		-e 's!git://(git.kernel.org/.*)!\0|https://\1!')
> +	remote=$(git remote -v | grep -m 1 -P "$urls" | cut -f 1)
>  
>  	if [[ -z "$remote" ]]; then
> -		git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/')
> -		remote=$(git remote -v | grep -m 1 "$git_url" | cut -f 1)
> -
> -		if [[ -z "$remote" ]]; then
> -			echoerr "No git remote for url $url or $git_url found in $(pwd)"
> -			echoerr "Please set it up using:"
> -			echoerr "    $ git remote add <name> $url"
> -			echoerr "with a name of your choice."
> -			return 1
> -		fi
> +		echoerr "No git remote for url $url found in $(pwd)"
> +		echoerr "Please set it up using:"
> +		echoerr "    $ git remote add <name> url"
> +		echoerr "with a name of your choice and url one of: ${urls//|/, }"
> +		return 1
>  	fi
>  
>  	echo $remote




More information about the dri-devel mailing list